66from oc4ids_datastore_pipeline .registry import (
77 fetch_license_mappings ,
88 fetch_registered_datasets ,
9- get_license_name_from_url ,
9+ get_license_title_from_url ,
1010)
1111
1212
@@ -59,6 +59,7 @@ def test_fetch_license_mappings(mocker: MockerFixture) -> None:
5959 "license_1" : {
6060 "fields" : {
6161 "title" : {"value" : "License 1" },
62+ "title_short" : {"value" : "L1" },
6263 "urls" : {
6364 "values" : [
6465 {
@@ -80,6 +81,7 @@ def test_fetch_license_mappings(mocker: MockerFixture) -> None:
8081 "license_2" : {
8182 "fields" : {
8283 "title" : {"value" : "License 2" },
84+ "title_short" : {"value" : "L2" },
8385 "urls" : {
8486 "values" : [
8587 {
@@ -99,9 +101,18 @@ def test_fetch_license_mappings(mocker: MockerFixture) -> None:
99101 result = fetch_license_mappings ()
100102
101103 assert result == {
102- "https://license_1.com/license" : "License 1" ,
103- "https://license_1.com/different_url" : "License 1" ,
104- "https://license_2.com/license" : "License 2" ,
104+ "https://license_1.com/license" : {
105+ "title" : "License 1" ,
106+ "title_short" : "L1" ,
107+ },
108+ "https://license_1.com/different_url" : {
109+ "title" : "License 1" ,
110+ "title_short" : "L1" ,
111+ },
112+ "https://license_2.com/license" : {
113+ "title" : "License 2" ,
114+ "title_short" : "L2" ,
115+ },
105116 }
106117
107118
@@ -116,32 +127,60 @@ def test_fetch_license_mappings_catches_exception(
116127 assert result == {}
117128
118129
119- def test_get_license_name_from_url (mocker : MockerFixture ) -> None :
130+ def test_get_license_title_from_url (mocker : MockerFixture ) -> None :
120131 patch_license_mappings = mocker .patch (
121132 "oc4ids_datastore_pipeline.registry.fetch_license_mappings"
122133 )
123134 patch_license_mappings .return_value = {
124- "https://license_1.com/license" : "License 1" ,
125- "https://license_2.com/license" : "License 2" ,
135+ "https://license_1.com/license" : {
136+ "title" : "License 1" ,
137+ "title_short" : "L1" ,
138+ },
139+ "https://license_2.com/license" : {
140+ "title" : "License 2" ,
141+ "title_short" : "L2" ,
142+ },
126143 }
127144
128- license_name = get_license_name_from_url (
145+ license_title = get_license_title_from_url (
129146 "https://license_2.com/license" , force_refresh = True
130147 )
131148
132- assert license_name == "License 2"
149+ assert license_title == ( "License 2" , "L2" )
133150
134151
135- def test_get_license_name_from_url_not_in_mapping (mocker : MockerFixture ) -> None :
152+ def test_get_license_title_from_url_not_in_mapping (mocker : MockerFixture ) -> None :
136153 patch_license_mappings = mocker .patch (
137154 "oc4ids_datastore_pipeline.registry.fetch_license_mappings"
138155 )
139156 patch_license_mappings .return_value = {
140- "https://license_1.com/license" : "License 1" ,
157+ "https://license_1.com/license" : {
158+ "title" : "License 1" ,
159+ "title_short" : "L1" ,
160+ },
141161 }
142162
143- license_name = get_license_name_from_url (
163+ license_title = get_license_title_from_url (
144164 "https://license_2.com/license" , force_refresh = True
145165 )
146166
147- assert license_name is None
167+ assert license_title == (None , None )
168+
169+
170+ def test_get_license_name_from_url_short_name_not_in_mapping (
171+ mocker : MockerFixture ,
172+ ) -> None :
173+ patch_license_mappings = mocker .patch (
174+ "oc4ids_datastore_pipeline.registry.fetch_license_mappings"
175+ )
176+ patch_license_mappings .return_value = {
177+ "https://license_2.com/license" : {
178+ "title" : "License 2" ,
179+ },
180+ }
181+
182+ license_title = get_license_title_from_url (
183+ "https://license_2.com/license" , force_refresh = True
184+ )
185+
186+ assert license_title == ("License 2" , None )
0 commit comments