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 _upgrade_to_0dot3(self, db):
        cursor = db.cursor()
        cursor.execute("ALTER TABLE asa_artifact_wiki RENAME TO asa_artifact_wiki_references;")
        for table in schema: # TODO: fix. reference to global var
            if table.name == "asa_artifact_artifact_references":
                self._create_table(table, cursor)
                break

        from AdaptiveArtifacts.persistence.data import DBPool
        from AdaptiveArtifacts.model.pool import InstancePool
        from AdaptiveArtifacts.model.core import Instance
        dbp = DBPool(self.env, InstancePool())
        dbp.load_specs()
        dbp.load_artifacts_of(Instance.get_name())
        for artifact in dbp.pool.get_instances_of(Instance.get_name()):
            dbp.update_artifact_ref_count(artifact, db)

        cursor.execute("UPDATE system SET value='0.3' WHERE name='%s'" % (self.db_key,))
        self.log.info('Upgraded ASA tables from versions 0.1/0.2 to 0.3')
    def _upgrade_to_0dot3(self, db):
        cursor = db.cursor()
        cursor.execute(
            "ALTER TABLE asa_artifact_wiki RENAME TO asa_artifact_wiki_references;"
        )
        for table in schema:  # TODO: fix. reference to global var
            if table.name == "asa_artifact_artifact_references":
                self._create_table(table, cursor)
                break

        from AdaptiveArtifacts.persistence.data import DBPool
        from AdaptiveArtifacts.model.pool import InstancePool
        from AdaptiveArtifacts.model.core import Instance
        dbp = DBPool(self.env, InstancePool())
        dbp.load_specs()
        dbp.load_artifacts_of(Instance.get_name())
        for artifact in dbp.pool.get_instances_of(Instance.get_name()):
            dbp.update_artifact_ref_count(artifact, db)

        cursor.execute("UPDATE system SET value='0.3' WHERE name='%s'" %
                       (self.db_key, ))
        self.log.info('Upgraded ASA tables from versions 0.1/0.2 to 0.3')