Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(project_client): delete dead code #793

Merged
merged 5 commits into from
Feb 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
18 changes: 0 additions & 18 deletions src/dsp_tools/commands/xmlupload/project_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,9 @@ class ProjectClient(Protocol):
def get_project_iri(self) -> str:
"""Get the IRI of the project to which the data is being uploaded."""

def get_ontology_iris(self) -> list[str]:
"""Get the ontology IRIs of the project to which the data is being uploaded."""

def get_ontology_name_dict(self) -> dict[str, str]:
"""Returns a mapping of ontology names to ontology IRIs."""

def get_ontology_iri_dict(self) -> dict[str, str]:
"""Returns a mapping of ontology IRIs to ontology names."""


@dataclass()
class ProjectClientLive:
Expand All @@ -47,24 +41,12 @@ def get_project_iri(self) -> str:
self.project_info = _get_project_info_from_server(self.con, self.shortcode)
return self.project_info.project_iri

def get_ontology_iris(self) -> list[str]:
"""Get the ontology IRIs of the project to which the data is being uploaded."""
if not self.project_info:
self.project_info = _get_project_info_from_server(self.con, self.shortcode)
return self.project_info.ontology_iris

def get_ontology_name_dict(self) -> dict[str, str]:
"""Returns a mapping of ontology names to ontology IRIs."""
if not self.project_info:
self.project_info = _get_project_info_from_server(self.con, self.shortcode)
return {_extract_name_from_onto_iri(iri): iri for iri in self.project_info.ontology_iris}

def get_ontology_iri_dict(self) -> dict[str, str]:
"""Returns a mapping of ontology IRIs to ontology names."""
if not self.project_info:
self.project_info = _get_project_info_from_server(self.con, self.shortcode)
return {iri: _extract_name_from_onto_iri(iri) for iri in self.project_info.ontology_iris}


def _get_project_info_from_server(con: Connection, shortcode: str) -> ProjectInfo:
project_iri = _get_project_iri_from_server(con, shortcode)
Expand Down
13 changes: 0 additions & 13 deletions test/e2e/commands/xmlupload/test_project_client_live.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,8 @@ def test_get_project_iri(project_client: ProjectClient) -> None:
assert project_iri == "http://rdfh.ch/projects/0001"


def test_get_ontology_iris(project_client: ProjectClient) -> None:
ontology_iris = project_client.get_ontology_iris()
expected = "http://0.0.0.0:3333/ontology/0001/anything/v2"
assert expected in ontology_iris


def test_get_ontology_name_dict(project_client: ProjectClient) -> None:
ontology_name_dict = project_client.get_ontology_name_dict()
expected_key = "anything"
expected_val = "http://0.0.0.0:3333/ontology/0001/anything/v2"
assert ontology_name_dict[expected_key] == expected_val


def test_get_ontology_iri_dict(project_client: ProjectClient) -> None:
ontology_iri_dict = project_client.get_ontology_iri_dict()
expected_key = "http://0.0.0.0:3333/ontology/0001/anything/v2"
expected_val = "anything"
assert ontology_iri_dict[expected_key] == expected_val
26 changes: 0 additions & 26 deletions test/unittests/commands/xmlupload/test_project_client_live.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,6 @@ def test_get_project_iri(self) -> None:
expected = "http://www.example.org/projects#a"
assert project_iri == expected

def test_get_ontology_iris(self) -> None:
project_iri_response = {"project": {"id": "http://www.example.org/projects#a"}}
project_ontologies_response = {"@id": "http://www.example.org/ontologies/a.1/v2"}
con = ConnectionMock([project_iri_response, project_ontologies_response])
project_client = ProjectClientLive(con, "")
ontology_iris = project_client.get_ontology_iris()
expected = ["http://www.example.org/ontologies/a.1/v2"]
assert ontology_iris == expected

def test_get_ontology_name_dict(self) -> None:
project_iri_response = {"project": {"id": "http://www.example.org/projects#a"}}
project_ontologies_response = {
Expand All @@ -54,20 +45,3 @@ def test_get_ontology_name_dict(self) -> None:
"a.2": "http://www.example.org/ontologies/a.2/v2",
}
assert ontology_name_dict == expected

def test_get_ontology_iri_dict(self) -> None:
project_iri_response = {"project": {"id": "http://www.example.org/projects#a"}}
project_ontologies_response = {
"@graph": [
{"@id": "http://www.example.org/ontologies/a.1/v2"},
{"@id": "http://www.example.org/ontologies/a.2/v2"},
]
}
con = ConnectionMock([project_iri_response, project_ontologies_response])
project_client = ProjectClientLive(con, "")
ontology_iri_dict = project_client.get_ontology_iri_dict()
expected = {
"http://www.example.org/ontologies/a.1/v2": "a.1",
"http://www.example.org/ontologies/a.2/v2": "a.2",
}
assert ontology_iri_dict == expected