def test_remove_component_not_exists(): """Test component remove not exists.""" dep_manager = _DependenciesManager() with pytest.raises(ValueError, match=r"Component .* of type .* not present."): dep_manager.remove_component( ProtocolConfig("a_protocol", "author", "0.1.0").component_id)
def test_remove_component_success(): """Test remove registered component.""" dep_manager = _DependenciesManager() protocol = ProtocolConfig("a_protocol", "author", "0.1.0") skill = SkillConfig("skill", "author", "0.1.0", protocols=[protocol.public_id]) dep_manager.add_component(protocol) dep_manager.add_component(skill) dep_manager.remove_component(skill.component_id)
def test_dependency_manager_highest_version(): """Test dependency version priority.""" dep_manager = _DependenciesManager() dep_manager.add_component(ProtocolConfig("a_protocol", "author", "0.1.0")) dep_manager.add_component(ProtocolConfig("a_protocol", "author", "0.2.0")) assert len(dep_manager.dependencies_highest_version) == 1 assert list(dep_manager.dependencies_highest_version)[0].version == "0.2.0" assert len(dep_manager.protocols) == 2 assert len(dep_manager.skills) == 0 assert len(dep_manager.contracts) == 0
def test_remove_component_depends_on_fail(): """Test component remove fails cause dependency.""" dep_manager = _DependenciesManager() protocol = ProtocolConfig("a_protocol", "author", "0.1.0") dep_manager.add_component(protocol) dep_manager.add_component( SkillConfig("skill", "author", "0.1.0", protocols=[protocol.public_id]) ) with pytest.raises( ValueError, match=r"Cannot remove component .* of type .*. Other components depends on it: .*", ): dep_manager.remove_component(protocol.component_id)