Applying a few corrections
This commit is contained in:
parent
69a8ed2378
commit
89f6909aff
2 changed files with 13 additions and 11 deletions
|
|
@ -64,7 +64,7 @@ class ComponentHandler:
|
||||||
"""
|
"""
|
||||||
self._set_component(component)
|
self._set_component(component)
|
||||||
self.db_names.append(component.name)
|
self.db_names.append(component.name)
|
||||||
self.host.tags.add(component.name, category="component")
|
self.host.tags.add(component.name, category="components")
|
||||||
component.at_added(self.host)
|
component.at_added(self.host)
|
||||||
|
|
||||||
def add_default(self, name):
|
def add_default(self, name):
|
||||||
|
|
@ -85,7 +85,7 @@ class ComponentHandler:
|
||||||
new_component = component.default_create(self.host)
|
new_component = component.default_create(self.host)
|
||||||
self._set_component(new_component)
|
self._set_component(new_component)
|
||||||
self.db_names.append(name)
|
self.db_names.append(name)
|
||||||
self.host.tags.add(name, category="component")
|
self.host.tags.add(name, category="components")
|
||||||
new_component.at_added(self.host)
|
new_component.at_added(self.host)
|
||||||
|
|
||||||
def remove(self, component):
|
def remove(self, component):
|
||||||
|
|
@ -102,7 +102,7 @@ class ComponentHandler:
|
||||||
if component_name in self._loaded_components:
|
if component_name in self._loaded_components:
|
||||||
component.at_removed(self.host)
|
component.at_removed(self.host)
|
||||||
self.db_names.remove(component_name)
|
self.db_names.remove(component_name)
|
||||||
self.host.tags.remove(component_name, category="component")
|
self.host.tags.remove(component_name, category="components")
|
||||||
del self._loaded_components[component_name]
|
del self._loaded_components[component_name]
|
||||||
else:
|
else:
|
||||||
message = f"Cannot remove {component_name} from {self.host.name} as it is not registered."
|
message = f"Cannot remove {component_name} from {self.host.name} as it is not registered."
|
||||||
|
|
@ -125,7 +125,7 @@ class ComponentHandler:
|
||||||
|
|
||||||
instance.at_removed(self.host)
|
instance.at_removed(self.host)
|
||||||
self.db_names.remove(name)
|
self.db_names.remove(name)
|
||||||
self.host.tags.remove(name, category="component")
|
self.host.tags.remove(name, category="components")
|
||||||
del self._loaded_components[name]
|
del self._loaded_components[name]
|
||||||
|
|
||||||
def get(self, name):
|
def get(self, name):
|
||||||
|
|
@ -226,7 +226,7 @@ class ComponentHolderMixin(object):
|
||||||
"""
|
"""
|
||||||
super().basetype_posthook_setup()
|
super().basetype_posthook_setup()
|
||||||
for component_name in self.db.component_names:
|
for component_name in self.db.component_names:
|
||||||
self.tags.add(component_name, category="component")
|
self.tags.add(component_name, category="components")
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def components(self) -> ComponentHandler:
|
def components(self) -> ComponentHandler:
|
||||||
|
|
|
||||||
|
|
@ -118,26 +118,28 @@ class TestComponents(EvenniaTest):
|
||||||
self.char1.components.add(rct)
|
self.char1.components.add(rct)
|
||||||
test_c = self.char1.components.get('test_c')
|
test_c = self.char1.components.get('test_c')
|
||||||
|
|
||||||
assert self.char1.tags.has(key="test_c", category="component")
|
assert self.char1.tags.has(key="test_c", category="components")
|
||||||
|
|
||||||
def test_host_has_added_default_component_tags(self):
|
def test_host_has_added_default_component_tags(self):
|
||||||
self.char1.components.add_default("test_c")
|
self.char1.components.add_default("test_c")
|
||||||
test_c = self.char1.components.get("test_c")
|
test_c = self.char1.components.get("test_c")
|
||||||
|
|
||||||
assert self.char1.tags.has(key="test_c", category="component")
|
assert self.char1.tags.has(key="test_c", category="components")
|
||||||
|
|
||||||
def test_host_remove_component_tags(self):
|
def test_host_remove_component_tags(self):
|
||||||
rct = RuntimeComponentTestC.create(self.char1)
|
rct = RuntimeComponentTestC.create(self.char1)
|
||||||
handler = self.char1.components
|
handler = self.char1.components
|
||||||
handler.add(rct)
|
handler.add(rct)
|
||||||
assert self.char1.tags.has(key="test_c", category="component")
|
assert self.char1.tags.has(key="test_c", category="components")
|
||||||
handler.remove(rct)
|
handler.remove(rct)
|
||||||
assert not self.char1.tags.has(key="test_c", category="component")
|
|
||||||
|
assert not self.char1.tags.has(key="test_c", category="components")
|
||||||
|
|
||||||
def test_host_remove_by_name_component_tags(self):
|
def test_host_remove_by_name_component_tags(self):
|
||||||
rct = RuntimeComponentTestC.create(self.char1)
|
rct = RuntimeComponentTestC.create(self.char1)
|
||||||
handler = self.char1.components
|
handler = self.char1.components
|
||||||
handler.add(rct)
|
handler.add(rct)
|
||||||
assert self.char1.tags.has(key="test_c", category="component")
|
assert self.char1.tags.has(key="test_c", category="components")
|
||||||
handler.remove_by_name("test_c")
|
handler.remove_by_name("test_c")
|
||||||
assert not self.char1.tags.has(key="test_c", category="component")
|
|
||||||
|
assert not self.char1.tags.has(key="test_c", category="components")
|
||||||
Loading…
Add table
Add a link
Reference in a new issue