Skip to content

Commit

Permalink
fix unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jnussbaum committed Apr 16, 2024
1 parent cd8c824 commit 1fc913f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions dsp_permissions_scripts/oap/oap_serialize.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ def _read_all_oaps_from_files(
val_oaps: list[ValueOap] = []
for file in folder.glob("**/*.json"):
content = file.read_text(encoding="utf-8")
val_oaps = []
if "_values_" in file.name:
val_oaps.append(ValueOap.model_validate_json(content))
else:
Expand All @@ -77,8 +76,9 @@ def _group_oaps_together(res_oaps: list[ResourceOap], val_oaps: list[ValueOap])
deserialized_resource_iris = []

for res_iri, _val_oaps in itertools.groupby(val_oaps, key=lambda x: x.resource_iri):
res_oap = next(x for x in res_oaps if x.resource_iri == res_iri)
oaps.append(Oap(resource_oap=res_oap, value_oaps=list(_val_oaps)))
res_oaps_filtered = [x for x in res_oaps if x.resource_iri == res_iri]
res_oap = res_oaps_filtered[0] if res_oaps_filtered else None
oaps.append(Oap(resource_oap=res_oap, value_oaps=sorted(_val_oaps, key=lambda x: x.value_iri)))
deserialized_resource_iris.append(res_iri)

remaining_res_oaps = [oap for oap in res_oaps if oap.resource_iri not in deserialized_resource_iris]
Expand Down
4 changes: 2 additions & 2 deletions tests/test_oap_serialization.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ def tearDown(self) -> None:
shutil.rmtree(testdata_dir)

def test_oap_serialization(self) -> None:
oap1 = self._get_oap_full()
oap2 = self._get_oap_one_value_only()
oap1 = self._get_oap_one_value_only()
oap2 = self._get_oap_full()
oap3 = self._get_oap_res_only()

serialize_oaps([oap1, oap2, oap3], self.shortcode, "original")
Expand Down

0 comments on commit 1fc913f

Please sign in to comment.