def test_find_migrations_no_migrations(self, mock_iter): def fake_iter_modules(blah): yield 'blah', 'zebra01', 'blah' yield 'blah', 'yellow01', 'blah' yield 'blah', 'xray01', 'blah' yield 'blah', 'wrinkle01', 'blah' yield 'blah', 'victor01', 'blah' mock_iter.side_effect = fake_iter_modules actual = data_migrations._find_migration_modules('umbrella') self.assertEqual(0, len(actual)) self.assertEqual([], actual)
def test_find_migrations_no_migrations(self, mock_iter): def fake_iter_modules(blah): yield 'blah', 'liberty01', 'blah' yield 'blah', 'kilo01', 'blah' yield 'blah', 'mitaka01', 'blah' yield 'blah', 'newton01', 'blah' yield 'blah', 'pike01', 'blah' mock_iter.side_effect = fake_iter_modules actual = data_migrations._find_migration_modules('ocata') self.assertEqual(0, len(actual)) self.assertEqual([], actual)
def test_find_migrations(self, mock_iter, mock_import): def fake_iter_modules(blah): yield 'blah', 'zebra01', 'blah' yield 'blah', 'zebra02', 'blah' yield 'blah', 'yellow01', 'blah' yield 'blah', 'xray01', 'blah' yield 'blah', 'wrinkle01', 'blah' mock_iter.side_effect = fake_iter_modules zebra1 = mock.Mock() zebra1.has_migrations.return_value = mock.Mock() zebra1.migrate.return_value = mock.Mock() zebra2 = mock.Mock() zebra2.has_migrations.return_value = mock.Mock() zebra2.migrate.return_value = mock.Mock() fake_imported_modules = [zebra1, zebra2] mock_import.side_effect = fake_imported_modules actual = data_migrations._find_migration_modules('zebra') self.assertEqual(2, len(actual)) self.assertEqual(fake_imported_modules, actual)
def test_find_migrations(self, mock_iter, mock_import): def fake_iter_modules(blah): yield 'blah', 'ocata01', 'blah' yield 'blah', 'ocata02', 'blah' yield 'blah', 'pike01', 'blah' yield 'blah', 'newton', 'blah' yield 'blah', 'mitaka456', 'blah' mock_iter.side_effect = fake_iter_modules ocata1 = mock.Mock() ocata1.has_migrations.return_value = mock.Mock() ocata1.migrate.return_value = mock.Mock() ocata2 = mock.Mock() ocata2.has_migrations.return_value = mock.Mock() ocata2.migrate.return_value = mock.Mock() fake_imported_modules = [ocata1, ocata2] mock_import.side_effect = fake_imported_modules actual = data_migrations._find_migration_modules('ocata') self.assertEqual(2, len(actual)) self.assertEqual(fake_imported_modules, actual)