def test_delete_new(self): pool = InstancePool() dbp = DBPool(self.env, pool) dbp.load_artifact(self.lightningMcQueen.get_id()) sallyCarrera = self.Car() pool.add(sallyCarrera) dbp = DBPool(self.env, pool) dbp.delete(sallyCarrera, 'me', 'deleted stuff', '127.0.0.1') self.assertEqual(3, len(dbp.pool.get_items((0,1))))
def test_load_artifacts_of_spec(self): # add a couple more instances pool = InstancePool() dbp = DBPool(self.env, pool) dbp.load_specs() car1 = self.Car(values={"License": "GO-42-42"}) plane2 = self.Vehicle(values={"License": "GO-55-55"}) pool.add(car1) pool.add(plane2) dbp.save('me', 'a couple more instances', '127.0.0.1') # load cars only pool = InstancePool() dbp = DBPool(self.env, pool) dbp.load_artifacts_of(self.Car.get_name()) self.assertEqual(len(pool.get_items((0,))), 2) self.assertTrue(not pool.get_item(self.lightningMcQueen.get_id()) is None) self.assertTrue(not pool.get_item(car1.get_id()) is None)
def setUp(self): self.env = EnvironmentStub(enable=['trac.*', 'AdaptiveArtifacts.*', 'AdaptiveArtifacts.persistence.db.*']) Setup(self.env).upgrade_environment(self.env.get_db_cnx()) self.Vehicle = Entity(name="Vehicle") self.Car = Entity(name="Car", bases=(self.Vehicle,), attributes=[Attribute(name="Wheels", multiplicity=4, atype=str)] ) self.lightningMcQueen = self.Car( values={"Wheels": ['front left wheel', 'front right wheel', 'rear left wheel', 'front right wheel']} ) pool = InstancePool() pool.add(self.Vehicle) pool.add(self.Car) pool.add(self.lightningMcQueen) dbp = DBPool(self.env, pool) dbp.save('anonymous',"","120.0.0.1")