def test_agent_factory_on_empty(): assert isinstance(agent.agent_factory("bla", agent.cfg.person), agent.PersonAgent) assert isinstance(agent.agent_factory("bla", agent.cfg.software), agent.SoftwareAgent) assert isinstance(agent.agent_factory("bla", agent.cfg.organization), agent.OrganizationAgent)
def test_organization_agent(): assert agent.OrganizationAgent("bla", uri="testuri").uri == "testuri" data = {"name": ["testorganization"], "homepage": ["https://diggr.link"]} o_agent = agent.agent_factory("bla", agent.cfg.organization) o_agent.update(data) assert o_agent.name == data["name"] assert o_agent.homepage == data["homepage"] for key in ["uri", "type", "slug", "name", "homepage"]: assert key in o_agent.to_json() assert isinstance(o_agent.graph(), rdflib.graph.Graph)
def test_software_agent(): assert agent.SoftwareAgent("test", uri="testuri").uri == "testuri" s_agent = agent.agent_factory("bla", agent.cfg.software) data = { "name": ["testagent"], "homepage": ["https://diggr.link"], "version": ["1.0"], } s_agent.update(data) assert s_agent.name == data["name"] assert s_agent.homepage == data["homepage"] assert s_agent.version == data["version"] for key in ["uri", "type", "slug", "name", "version", "homepage"]: assert key in s_agent.to_json() for key, value in data.items(): assert s_agent.to_json()[key] == value assert isinstance(s_agent.graph(), rdflib.graph.Graph)
def test_person_agent(): assert agent.PersonAgent("bla", uri="testuri").uri == "testuri" data = { "name": ["testperson"], "homepage": ["https://diggr.link"], "email": ["test"], "institution": ["ubleipzig"], } p_agent = agent.agent_factory("bla", agent.cfg.person) p_agent.update(data) assert p_agent.name == data["name"] assert p_agent.homepage == data["homepage"] assert p_agent.institution == data["institution"] assert p_agent.email == data["email"] for key in [ "uri", "type", "slug", "name", "homepage", "email", "institution" ]: assert key in p_agent.to_json() assert isinstance(p_agent.graph(), rdflib.graph.Graph)
def test_agent_factory(prov_path_with_agents): agent.cfg = get_config(prov_path_with_agents) agents = agent.load_agent_profiles() check_attrs(agent.agent_factory("johndoe", agent.PersonAgent), PA)