def test_edit_spec_name(self):
        pool = InstancePool()
        dbp = DBPool(self.env, pool)
        dbp.load_spec("Car")
        Car = dbp.pool.get_item("Car")

        # create three more versions
        Car._is_modified = True
        dbp.save('me', 'a new version', '127.0.0.1')
        Car._is_modified = True
        dbp.save('me', 'a new version', '127.0.0.1')
        Car._is_modified = True
        dbp.save('me', 'a new version', '127.0.0.1')

        # so, there should be 4 versions now
        ch = [(version, timestamp, author, ipnr, comment) for version, timestamp, author, ipnr, comment in dbp.get_history(Car)]
        self.assertEqual(len(ch), 4)

        # edit the name
        Car._replace_name("Automobile")
        dbp.save('me', 'a couple more instances', '127.0.0.1')

        # querying by the new name should render 5 versions
        self.assertEqual(Car.get_name(), "Automobile")
        ch = [(version, timestamp, author, ipnr, comment) for version, timestamp, author, ipnr, comment in dbp.get_history(Car)]
        self.assertEqual(len(ch), 5)
    def build_saved_and_reloaded_pool(testcase):
        testcase.env = EnvironmentStub(enable=['trac.*', 'AdaptiveArtifacts.*', 'AdaptiveArtifacts.persistence.db.*'])
        Setup(testcase.env).upgrade_environment(testcase.env.get_db_cnx())

        # this works as far as no one inherits from MetaModelInstancesStructureAfterLoad and ModelInstancesStructureAfterLoad
        super(testcase.__class__, testcase).setUp()

        dbp = DBPool(testcase.env, testcase.pool)
        dbp.save('anonymous',"","120.0.0.1")

        new_pool = InstancePool()
        new_dbp = DBPool(testcase.env, new_pool)
        for instance in testcase.pool.get_instances_of(Instance.get_name()):
            new_dbp.load_artifact(instance.get_id())
        for entity in testcase.pool.get_instances_of(Entity.get_name()):
            new_dbp.load_spec(entity.get_name())

        testcase.pool = new_pool