Skip to content

Commit

Permalink
removed redundant patching / mocking of jvm stop
Browse files Browse the repository at this point in the history
  • Loading branch information
LckyLke committed Nov 25, 2024
1 parent af35800 commit b4f200d
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions tests/test_owlapy_serve.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,39 +11,41 @@
ontology = SyncOntologyManager().load_ontology(ontology_path)
reasoner = SyncReasoner(ontology=ontology, reasoner=reasoner_name)

@patch("owlapy.scripts.owlapy_serve.stopJVM")
@pytest.fixture()
def mock_stop_jvm():
patcher = patch("owlapy.scripts.owlapy_serve.stopJVM")
patcher.start()
yield
patcher.stop()

def test_get_classes (mock_stop_jvm):
with TestClient(create_app(ontology_path, reasoner_name)) as client:
response = client.get("/classes")
expected_classes = [cls.__str__() for cls in ontology.classes_in_signature()]
assert response.status_code == 200
assert set(response.json()["classes"]) == set(expected_classes)

@patch("owlapy.scripts.owlapy_serve.stopJVM")
def test_get_individuals(mock_stop_jvm):
with TestClient(create_app(ontology_path, reasoner_name)) as client:
response = client.get("/individuals")
expected_individuals = [ind.__str__() for ind in ontology.individuals_in_signature()]
assert response.status_code == 200
assert set(response.json()["individuals"]) == set(expected_individuals)

@patch("owlapy.scripts.owlapy_serve.stopJVM")
def test_get_abox(mock_stop_jvm):
with TestClient(create_app(ontology_path, reasoner_name)) as client:
response = client.get("/abox")
expected_abox = [axiom.__str__() for axiom in ontology.get_abox_axioms()]
assert response.status_code == 200
assert set(response.json()["abox"]) == set(expected_abox)

@patch("owlapy.scripts.owlapy_serve.stopJVM")
def test_get_tbox(mock_stop_jvm):
with TestClient(create_app(ontology_path, reasoner_name)) as client:
response = client.get("/tbox")
expected_tbox = [axiom.__str__() for axiom in ontology.get_tbox_axioms()]
assert response.status_code == 200
assert set(response.json()["tbox"]) == set(expected_tbox)

@patch("owlapy.scripts.owlapy_serve.stopJVM")
def test_get_instances(mock_stop_jvm):
with TestClient(create_app(ontology_path, reasoner_name)) as client:
test_class_iri = "http://www.benchmark.org/family#Child"
Expand Down

0 comments on commit b4f200d

Please sign in to comment.