class BundleModelTest(unittest.TestCase): def setUp(self): MockBundle._tester = self self.engine = create_engine('sqlite://', strategy='threadlocal') self.model = BundleModel(self.engine) # We'll test the result of this schema creation step in test_create_tables. self.model.create_tables() def tearDown(self): self.model = None self.engine = None def test_create_tables(self): inspector = Inspector.from_engine(self.engine) tables = set(inspector.get_table_names()) for table in db_metadata.tables: self.assertIn(table, tables) def test_save_and_get_bundle(self): bundle = MockBundle() self.model.save_bundle(bundle) self.assertTrue(bundle._validate_called) get_bundle_subclass_path = 'codalab.model.bundle_model.get_bundle_subclass' with mock.patch(get_bundle_subclass_path, lambda bundle_type: MockBundle): retrieved_bundle = self.model.get_bundle(bundle.uuid) self.assertTrue(isinstance(retrieved_bundle, MockBundle)) self.assertTrue(retrieved_bundle._validate_called)
def setUp(self): MockBundle._tester = self MockDependency._tester = self self.engine = create_engine('sqlite://', strategy='threadlocal') self.model = BundleModel(self.engine, {}) # We'll test the result of this schema creation step in test_create_tables. self.model.create_tables()
class BundleModelTest(unittest.TestCase): def setUp(self): MockBundle._tester = self MockDependency._tester = self self.engine = create_engine('sqlite://', strategy='threadlocal') self.model = BundleModel(self.engine, {}) # We'll test the result of this schema creation step in test_create_tables. self.model.create_tables() def tearDown(self): self.model = None self.engine = None def test_create_tables(self): inspector = Inspector.from_engine(self.engine) tables = set(inspector.get_table_names()) for table in db_metadata.tables: self.assertIn(table, tables) def test_save_and_get_bundle(self): bundle = MockBundle() self.model.save_bundle(bundle) self.assertTrue(bundle._validate_called) get_bundle_subclass_path = 'codalab.model.bundle_model.get_bundle_subclass' with mock.patch(get_bundle_subclass_path, lambda bundle_type: MockBundle): retrieved_bundle = self.model.get_bundle(bundle.uuid) self.assertTrue(isinstance(retrieved_bundle, MockBundle)) self.assertTrue(retrieved_bundle._validate_called)
def setUp(self): MockBundle._tester = self MockDependency._tester = self self.engine = create_engine('sqlite://', strategy='threadlocal') self.model = BundleModel(self.engine) # We'll test the result of this schema creation step in test_create_tables. self.model.create_tables()