11import datetime
2+ import pytest
23import fairgraph .openminds .core as omcore
34import fairgraph .openminds .publications as ompub
5+ from fairgraph .kgproxy import KGProxy
6+ from fairgraph .caching import object_cache
47
58
69def test_get_journal ():
@@ -25,6 +28,34 @@ def test_get_journal():
2528 assert article .get_citation_string (client = None ) == expected
2629
2730
31+ def test_get_journal_with_issue_proxy_journal ():
32+ """When data comes from the KG, volume.is_part_of is a KGProxy, not a resolved Periodical.
33+ get_journal() should resolve the proxy rather than failing the isinstance assertion."""
34+ periodical_id = "https://kg.ebrains.eu/api/instances/00000000-0000-0000-0000-000000000001"
35+ jphysiol = ompub .Periodical (name = "The Journal of Physiology" , id = periodical_id )
36+ object_cache [periodical_id ] = jphysiol
37+
38+ try :
39+ journal_proxy = KGProxy (ompub .Periodical , periodical_id )
40+ volume = ompub .PublicationVolume (is_part_of = journal_proxy , volume_number = "117" )
41+ issue = ompub .PublicationIssue (is_part_of = volume , issue_number = "4" )
42+ article = ompub .ScholarlyArticle (
43+ name = "A quantitative description of membrane current and its application to conduction and excitation in nerve" ,
44+ authors = [
45+ omcore .Person (given_name = "AL" , family_name = "Hodgkin" ),
46+ omcore .Person (given_name = "AF" , family_name = "Huxley" ),
47+ ],
48+ is_part_of = issue ,
49+ publication_date = datetime .date (1952 , 8 , 1 ),
50+ pagination = "500–44" ,
51+ )
52+ assert article .get_journal (client = None ) == jphysiol
53+ assert article .get_journal (client = None , with_volume = True ) == (jphysiol , volume )
54+ assert article .get_journal (client = None , with_volume = True , with_issue = True ) == (jphysiol , volume , issue )
55+ finally :
56+ del object_cache [periodical_id ]
57+
58+
2859def test_get_journal_no_issue ():
2960 jphysiol = ompub .Periodical (name = "The Journal of Physiology" )
3061 volume = ompub .PublicationVolume (is_part_of = jphysiol , volume_number = "117" )
0 commit comments