Skip to content

Commit

Permalink
awards: fixed tests and mappings
Browse files Browse the repository at this point in the history
  • Loading branch information
0einstein0 committed Sep 25, 2024
1 parent 881d20a commit 7bd9767
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,12 @@
"type": "object",
"dynamic": "true"
},
"subject": {
"type": "keyword"
},
"scheme": {
"type": "keyword"
},
"identifiers": {
"properties": {
"identifier": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,12 @@
"type": "object",
"dynamic": "true"
},
"subject": {
"type": "keyword"
},
"scheme": {
"type": "keyword"
},
"identifiers": {
"properties": {
"identifier": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,12 @@
"type": "object",
"dynamic": "true"
},
"subject": {
"type": "keyword"
},
"scheme": {
"type": "keyword"
},
"identifiers": {
"properties": {
"identifier": {
Expand Down
17 changes: 17 additions & 0 deletions tests/contrib/affiliations/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,23 @@ def affiliation_full_data():
}


@pytest.fixture(scope="function")
def affiliation_openaire_data():
"""Full affiliation data."""
return {
"acronym": "CERN",
"id": "01ggx4157",
"identifiers": [{"identifier": "999988133", "scheme": "pic"}],
"name": "Test affiliation",
"title": {"en": "Test affiliation", "es": "Afiliacion de test"},
"country": "CH",
"country_name": "Switzerland",
"location_name": "Geneva",
"status": "active",
"types": ["facility", "funder"],
}


@pytest.fixture(scope="function")
def openaire_affiliation_full_data():
"""Full OpenAIRE affiliation data."""
Expand Down
12 changes: 6 additions & 6 deletions tests/contrib/affiliations/test_affiliations_datastreams.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,11 +173,15 @@ def test_openaire_organization_transformer(


def test_openaire_affiliations_service_writer(
app, search_clear, affiliation_full_data, openaire_affiliation_full_data, service
app,
search_clear,
affiliation_openaire_data,
openaire_affiliation_full_data,
service,
):
# create vocabulary with original service writer
orig_writer = AffiliationsServiceWriter()
orig_affiliation_rec = orig_writer.write(StreamEntry(affiliation_full_data))
orig_affiliation_rec = orig_writer.write(StreamEntry(affiliation_openaire_data))
orig_affiliation_dict = orig_affiliation_rec.entry.to_dict()
Affiliation.index.refresh() # refresh index to make changes live

Expand All @@ -193,10 +197,6 @@ def test_openaire_affiliations_service_writer(
# updating fields changing from one update to the other
orig_affiliation_dict["revision_id"] = affiliation_dict["revision_id"]
orig_affiliation_dict["updated"] = affiliation_dict["updated"]
# Adding the extra identifier coming from OpenAIRE
orig_affiliation_dict["identifiers"].extend(
openaire_affiliation_full_data["identifiers"]
)

assert dict(orig_affiliation_dict) == affiliation_dict

Expand Down
9 changes: 5 additions & 4 deletions tests/contrib/awards/test_awards_datastreams.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def dict_award_entry():
"enddate": "2010-09-30",
"funding": [
{
"funding_stream": {
"fundingStream": {
"description": "Directorate for Geosciences - Division of "
"Ocean Sciences",
"id": "NSF::GEO/OAD::GEO/OCE",
Expand Down Expand Up @@ -65,7 +65,7 @@ def dict_award_entry_ec():
"enddate": "2025-12-31",
"funding": [
{
"funding_stream": {
"fundingStream": {
"description": "Test stream",
"id": "TST::test::test",
},
Expand All @@ -92,10 +92,10 @@ def expected_from_award_json():
"id": "021nxhr62::0751743",
"identifiers": [{"identifier": "https://test.com", "scheme": "url"}],
"number": "0751743",
"program": "NSF::GEO/OAD::GEO/OCE",
"title": {"en": "Test title"},
"funder": {"id": "021nxhr62"},
"acronym": "TA",
"program": "GEO/OAD",
}


Expand All @@ -110,7 +110,7 @@ def expected_from_award_json_ec():
"title": {"en": "Test title"},
"funder": {"id": "00k4n6c32"},
"acronym": "TS",
"program": "test",
"program": "TST::test::test",
}


Expand Down Expand Up @@ -246,6 +246,7 @@ def test_awards_transformer_ec_functionality(
expected_from_award_json_ec,
):
transformer = OpenAIREProjectTransformer()

assert expected_from_award_json == transformer.apply(dict_award_entry).entry
assert expected_from_award_json_ec == transformer.apply(dict_award_entry_ec).entry

Expand Down

0 comments on commit 7bd9767

Please sign in to comment.