class CacheTableTestCase(unittest.TestCase): def setUp(self): self.db = mock.create_autospec(Connection, instance=True) self.setup = Mock([]) self.teardown = Mock([]) self.table = table = CacheTableSpec(self.setup, self.teardown) self.manager = CacheTableManager(self.db, [table]) def test_setup(self): self.manager.setup() self.setup.assert_called_once_with(self.db) self.teardown.assert_not_called() def test_cleanup(self): self.manager.teardown() self.setup.assert_not_called() self.teardown.assert_called_once_with(self.db)
class CacheTableTestCase(unittest.TestCase): def setUp(self): self.db = NonCallableMagicMock(SQLiteDB) self.setup = Mock([]) self.teardown = Mock([]) self.table = table = CacheTable(self.setup, self.teardown) self.manager = CacheTableManager(self.db, [table]) def test_setup(self): self.manager.setup() self.setup.assert_called_once_with(self.db) self.teardown.assert_not_called() def test_cleanup(self): self.manager.teardown() self.setup.assert_not_called() self.teardown.assert_called_once_with(self.db)