@@ -84,6 +84,38 @@ def test_replace_package_prefers_requested_language():
84
84
assert attribution_agent ["name" ] == "Nederlandse agent"
85
85
86
86
87
+ def test_replace_package_requested_language_empty_or_none ():
88
+ package = deepcopy (_base_package ())
89
+
90
+ # Set the requested language values to empty string and None
91
+ package ["title" ] = {"en" : "English title" , "nl" : "" }
92
+ package ["notes" ] = {"en" : "English notes" , "nl" : None }
93
+ package ["provenance" ] = {"en" : "English provenance" , "nl" : "" }
94
+ package ["population_coverage" ] = {"en" : "English coverage" , "nl" : None }
95
+ package ["publisher_note" ] = {"en" : "English publisher note" , "nl" : "" }
96
+
97
+ package ["resources" ][0 ]["name" ] = {"en" : "English resource" , "nl" : "" }
98
+ package ["resources" ][0 ]["rights" ] = {"en" : "English rights" , "nl" : None }
99
+
100
+ package ["qualified_attribution" ][0 ]["agent" ][0 ]["name" ] = {"en" : "English agent" , "nl" : "" }
101
+
102
+ result = replace_package (package , translation_dict = {}, lang = "nl" )
103
+
104
+ # Should fallback to English when nl is empty or None
105
+ assert result ["title" ] == "English title"
106
+ assert result ["notes" ] == "English notes"
107
+ assert result ["provenance" ] == "English provenance"
108
+ assert result ["population_coverage" ] == "English coverage"
109
+ assert result ["publisher_note" ] == "English publisher note"
110
+
111
+ resource = result ["resources" ][0 ]
112
+ assert resource ["name" ] == "English resource"
113
+ assert resource ["rights" ] == "English rights"
114
+
115
+ attribution_agent = result ["qualified_attribution" ][0 ]["agent" ][0 ]
116
+ assert attribution_agent ["name" ] == "English agent"
117
+
118
+
87
119
def test_replace_package_falls_back_to_default_language ():
88
120
package = deepcopy (_base_package ())
89
121
0 commit comments