1 from dmigrations
.tests
.common
import *
2 from dmigrations
.migration_state
import MigrationState
3 from dmigrations
.migration_db
import MigrationDb
4 from dmigrations
.migration_log
import get_log
5 from datetime
import datetime
, date
, time
7 class MigrationLogTest(TestCase
):
9 from django
.db
import connection
10 self
.cursor
= connection
.cursor()
13 "DROP TABLE smigrations_schema",
14 "DROP TABLE migrations",
15 "DROP TABLE migrations_log",
16 "CREATE TABLE mock (id INTEGER NOT NULL)"]:
17 try: self
.cursor
.execute(sql
)
21 self
.cursor
.execute("DROP TABLE mock")
23 def test_when_doing_something_then_loggged(self
):
24 db
= MigrationDb(directory
=self
.mock_migrations_dir
)
25 db
.warn
= WarningsMocker()
26 si
= MigrationState(migration_db
=db
, dev
=True)
30 si
.mark_as_unapplied('001_foo')
32 si
.mark_as_applied('005_omg')
37 ("apply", "001_foo", "success"),
38 ("mark_as_unapplied", "001_foo", "success"),
39 ("apply", "001_foo", "success"),
40 ("mark_as_applied", "005_omg", "success"),
41 ("unapply", "001_foo", "success"),
42 ], [row
[:3] for row
in get_log()]
44 self
.assert_equal(True, isinstance(get_log()[0][3], datetime
))