def test_it_should_create_migration_file(self, strftime_mock): self.assertFalse( os.path.exists( '20120303194030_create_a_file_test_migration.migration')) Migration.create('create_a_file_test_migration', '.') self.assertTrue( os.path.exists( '20120303194030_create_a_file_test_migration.migration'))
def test_it_should_raise_exception_if_an_error_hapens_when_writing_the_file( self, open_mock, strftime_mock): try: Migration.create('test_migration') self.fail('it should not pass here') except Exception as e: self.assertEqual( "could not create file ('./20120303194030_test_migration.migration')", str(e))
def test_it_should_use_local_time_when_asked_to_not_use_utc(self, localtime_mock): Migration.create('test_migration', utc_timestamp=False) localtime_mock.assert_called_once()
def test_it_should_use_gmt_time_when_asked_to_use_utc(self, gmtime_mock): Migration.create('test_migration', utc_timestamp=True) gmtime_mock.assert_called_once()
def test_it_should_raise_exception_if_an_error_hapens_when_writing_the_file(self, open_mock, strftime_mock): try: Migration.create('test_migration') self.fail('it should not pass here') except Exception as e: self.assertEqual("could not create file ('./20120303194030_test_migration.migration')", str(e))
def test_it_should_create_migration_file(self, strftime_mock): self.assertFalse(os.path.exists('20120303194030_create_a_file_test_migration.migration')) Migration.create('create_a_file_test_migration', '.') self.assertTrue(os.path.exists('20120303194030_create_a_file_test_migration.migration'))
def test_it_should_use_local_time_when_asked_to_not_use_utc( self, localtime_mock): Migration.create('test_migration', utc_timestamp=False) localtime_mock.assert_called_once()