11import copy
2- from typing import Dict , Any
2+ from typing import Any , Dict
33
44import pytest
55
@@ -22,15 +22,15 @@ def sample_dandiset_metadata() -> Dict[str, Any]:
2222 "roleName" : ["dcite:Author" , "dcite:ContactPerson" ],
2323 "identifier" : "0000-0001-2345-6789" ,
2424 "email" : "john.doe@example.com" ,
25- "includeInCitation" : True
25+ "includeInCitation" : True ,
2626 },
2727 {
2828 "schemaKey" : "Organization" ,
2929 "name" : "Test Organization" ,
3030 "roleName" : ["dcite:Sponsor" ],
3131 "identifier" : "https://ror.org/xxxxxxxxx" ,
32- "includeInCitation" : False
33- }
32+ "includeInCitation" : False ,
33+ },
3434 ],
3535 "license" : ["spdx:CC-BY-4.0" ],
3636 "schemaVersion" : "0.6.4" ,
@@ -41,63 +41,63 @@ def sample_dandiset_metadata() -> Dict[str, Any]:
4141 "dataStandard" : [
4242 {
4343 "name" : "Neurodata Without Borders (NWB)" ,
44- "identifier" : "RRID:SCR_015242"
44+ "identifier" : "RRID:SCR_015242" ,
4545 }
4646 ],
4747 "species" : [
4848 {
4949 "name" : "Homo sapiens" ,
50- "identifier" : "http://purl.obolibrary.org/obo/NCBITaxon_9606"
50+ "identifier" : "http://purl.obolibrary.org/obo/NCBITaxon_9606" ,
5151 }
5252 ],
5353 "approach" : [
5454 {
5555 "name" : "electrophysiology" ,
56- "identifier" : "http://uri.interlex.org/base/ilx_0739363"
56+ "identifier" : "http://uri.interlex.org/base/ilx_0739363" ,
5757 }
5858 ],
5959 "measurementTechnique" : [
6060 {
6161 "name" : "multi-electrode extracellular electrophysiology" ,
62- "identifier" : "http://uri.interlex.org/base/ilx_0739400"
62+ "identifier" : "http://uri.interlex.org/base/ilx_0739400" ,
6363 }
64- ]
65- }
64+ ],
65+ },
6666 }
6767
6868
6969def test_google_dataset_metadata_basic_transformation (sample_dandiset_metadata ):
7070 """Test that the basic transformation works correctly"""
7171 result = google_dataset_metadata (sample_dandiset_metadata )
72-
72+
7373 # Check that the original metadata is not modified
7474 assert sample_dandiset_metadata != result
75-
75+
7676 # Check that schema:Dataset is added to schemaKey
7777 assert "schema:Dataset" in result ["schemaKey" ]
78-
78+
7979 # Check that creator is properly formatted
8080 assert "creator" in result
8181 assert isinstance (result ["creator" ], list )
8282 assert len (result ["creator" ]) > 0
83-
83+
8484 # Check first creator
8585 creator = result ["creator" ][0 ]
8686 assert creator ["schemaKey" ] == "schema:Person"
8787 assert "name" in creator
88-
88+
8989 # Check that license is properly formatted
9090 assert "license" in result
9191 assert isinstance (result ["license" ], list )
9292 assert "https://spdx.org/licenses/CC-BY-4.0" in result ["license" ]
93-
93+
9494 # Check that version is present
9595 assert "version" in result
96-
96+
9797 # Check that identifier is properly formatted
9898 assert "identifier" in result
9999 assert result ["identifier" ] == "https://identifiers.org/DANDI:000707"
100-
100+
101101 # Check that keywords exist
102102 assert "keywords" in result
103103 assert isinstance (result ["keywords" ], list )
@@ -110,7 +110,7 @@ def test_google_dataset_metadata_preserves_original(sample_dandiset_metadata):
110110 """Test that the original metadata is not modified"""
111111 original = copy .deepcopy (sample_dandiset_metadata )
112112 google_dataset_metadata (sample_dandiset_metadata )
113-
113+
114114 # Verify the original is unchanged
115115 assert original == sample_dandiset_metadata
116116
@@ -122,12 +122,12 @@ def test_google_dataset_metadata_with_existing_creator(sample_dandiset_metadata)
122122 {
123123 "schemaKey" : "Person" ,
124124 "name" : "Jane Smith" ,
125- "identifier" : "https://orcid.org/0000-0002-3456-7890"
125+ "identifier" : "https://orcid.org/0000-0002-3456-7890" ,
126126 }
127127 ]
128-
128+
129129 result = google_dataset_metadata (sample_dandiset_metadata )
130-
130+
131131 # Check that the existing creator is preserved
132132 assert result ["creator" ] == sample_dandiset_metadata ["creator" ]
133133
@@ -136,13 +136,13 @@ def test_google_dataset_metadata_with_existing_keywords(sample_dandiset_metadata
136136 """Test that existing keywords are preserved and extended"""
137137 # Add keywords field
138138 sample_dandiset_metadata ["keywords" ] = ["test" , "example" ]
139-
139+
140140 result = google_dataset_metadata (sample_dandiset_metadata )
141-
141+
142142 # Check that the existing keywords are preserved
143143 assert "test" in result ["keywords" ]
144144 assert "example" in result ["keywords" ]
145-
145+
146146 # Check that additional keywords are added
147147 assert "neuroscience" in result ["keywords" ]
148148 assert "DANDI" in result ["keywords" ]
@@ -153,9 +153,9 @@ def test_google_dataset_metadata_with_no_license(sample_dandiset_metadata):
153153 # Remove license field
154154 no_license_metadata = copy .deepcopy (sample_dandiset_metadata )
155155 del no_license_metadata ["license" ]
156-
156+
157157 result = google_dataset_metadata (no_license_metadata )
158-
158+
159159 # Check that license is not in the result
160160 assert "license" not in result
161161
@@ -165,9 +165,9 @@ def test_google_dataset_metadata_with_no_contributors(sample_dandiset_metadata):
165165 # Remove contributor field
166166 no_contributor_metadata = copy .deepcopy (sample_dandiset_metadata )
167167 del no_contributor_metadata ["contributor" ]
168-
168+
169169 result = google_dataset_metadata (no_contributor_metadata )
170-
170+
171171 # Check that creator is not in the result
172172 assert "creator" not in result
173173
@@ -176,9 +176,9 @@ def test_google_dataset_metadata_with_date_published(sample_dandiset_metadata):
176176 """Test handling of datePublished field"""
177177 # Add datePublished field
178178 sample_dandiset_metadata ["datePublished" ] = "2023-01-01T00:00:00Z"
179-
179+
180180 result = google_dataset_metadata (sample_dandiset_metadata )
181-
181+
182182 # Check that datePublished is preserved
183183 assert result ["datePublished" ] == "2023-01-01T00:00:00Z"
184184
@@ -187,8 +187,8 @@ def test_google_dataset_metadata_with_date_created_fallback(sample_dandiset_meta
187187 """Test fallback to dateCreated when datePublished is not present"""
188188 # Add dateCreated field
189189 sample_dandiset_metadata ["dateCreated" ] = "2022-01-01T00:00:00Z"
190-
190+
191191 result = google_dataset_metadata (sample_dandiset_metadata )
192-
192+
193193 # Check that datePublished is set to dateCreated
194194 assert result ["datePublished" ] == "2022-01-01T00:00:00Z"
0 commit comments