Skip to content

Commit 0bbc799

Browse files
authored
Merge pull request #291 from LD4P/kallimathios-patch-2
Update bf_work.py
2 parents 780220f + 31d24d2 commit 0bbc799

File tree

5 files changed

+20
-21
lines changed

5 files changed

+20
-21
lines changed

ils_middleware/tasks/folio/mappings/bf_instance.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,16 @@
22
BF Instance with its associated BF Work.
33
"""
44

5+
editions = """PREFIX bf: <http://id.loc.gov/ontologies/bibframe/>
6+
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
7+
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
8+
SELECT ?edition
9+
WHERE {{
10+
<{bf_instance}> a bf:Instance .
11+
<{bf_instance}> bf:editionStatement ?edition .
12+
}}
13+
"""
14+
515
identifier = """PREFIX bf: <http://id.loc.gov/ontologies/bibframe/>
616
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
717
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>

ils_middleware/tasks/folio/mappings/bf_work.py

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,6 @@
2020
}}
2121
"""
2222

23-
editions = """PREFIX bf: <http://id.loc.gov/ontologies/bibframe/>
24-
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
25-
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
26-
27-
SELECT ?edition
28-
WHERE {{
29-
<{bf_work}> a bf:Work .
30-
<{bf_work}> bf:editionStatement ?edition .
31-
}}
32-
"""
33-
3423
instance_type_id = """PREFIX bf: <http://id.loc.gov/ontologies/bibframe/>
3524
3625
SELECT ?instance_type_id

tests/fixtures/bf.ttl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ bf:Work rdfs:label "http://id.loc.gov/ontologies/bibframe/Work" .
5858
bf:copyrightDate "©2020" ;
5959
bf:dimensions "30 cm by 15 cm"@eng ;
6060
bf:editionStatement "1a edizione"@ita ;
61+
bf:editionStatement "1st edition"@eng ;
6162
bf:electronicLocator <https://phaidra.cab.unipd.it/detail/o:445140?mycoll=o:432583>,
6263
<https://purl.stanford.edu/mf283yt5578> ;
6364
bf:extent [ a bf:Extent ;
@@ -115,7 +116,6 @@ bf:Work rdfs:label "http://id.loc.gov/ontologies/bibframe/Work" .
115116
[ a bf:Contribution ;
116117
bf:agent <http://id.loc.gov/authorities/names/n97060063> ;
117118
bf:role <http://id.loc.gov/vocabulary/relators/aut> ] ;
118-
bf:editionStatement "1st edition"@eng ;
119119
bf:genreForm <http://id.loc.gov/authorities/genreForms/gf2014026113> ;
120120
bf:hasInstance <https://api.stage.sinopia.io/resource/b0319047-acd0-4f30-bd8b-98e6c1bac6b0> ;
121121
bf:language <http://id.loc.gov/vocabulary/languages/ita> ;

tests/tasks/folio/mappings/test_bf_instance.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,15 @@
88
uri = "https://api.stage.sinopia.io/resource/b0319047-acd0-4f30-bd8b-98e6c1bac6b0"
99

1010

11+
@typing.no_type_check
12+
def test_edition(test_graph: rdflib.Graph):
13+
sparql = bf_instance_map.editions.format(bf_instance=uri)
14+
15+
editions = [row[0] for row in test_graph.query(sparql)]
16+
sorted_editions = sorted(editions, key=lambda x: x.value)
17+
assert str(sorted_editions[1]).startswith("1st edition")
18+
19+
1120
@typing.no_type_check
1221
def test_isbn(test_graph: rdflib.Graph):
1322
sparql = bf_instance_map.identifier.format(bf_instance=uri, bf_class="bf:Isbn")

tests/tasks/folio/mappings/test_bf_work.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,6 @@ def test_contributor_author_person(test_graph: rdflib.Graph):
1818
assert str(contributors[0][1]).startswith("author")
1919

2020

21-
@typing.no_type_check
22-
def test_edition(test_graph: rdflib.Graph):
23-
sparql = bf_work_map.editions.format(bf_work=work_uri)
24-
25-
editions = [row[0] for row in test_graph.query(sparql)]
26-
27-
assert str(editions[0]).startswith("1st edition")
28-
29-
3021
@typing.no_type_check
3122
def test_instance_type_id(test_graph: rdflib.Graph):
3223
sparql = bf_work_map.instance_type_id.format(bf_work=work_uri)

0 commit comments

Comments
 (0)