|
3 | 3 | from easyDataverse.dataset import Dataset |
4 | 4 |
|
5 | 5 | from easyDataverse.dataverse import Dataverse |
| 6 | +from easyDataverse.license import CustomLicense |
6 | 7 |
|
7 | 8 |
|
8 | 9 | class TestDatasetCreation: |
@@ -130,6 +131,66 @@ def test_creation_other_license( |
130 | 131 |
|
131 | 132 | assert self.sort_citation(dataset) == minimal_upload_other_license |
132 | 133 |
|
| 134 | + @pytest.mark.integration |
| 135 | + def test_creation_custom_terms_of_use( |
| 136 | + self, |
| 137 | + credentials, |
| 138 | + ): |
| 139 | + # Arrange |
| 140 | + base_url, api_token = credentials |
| 141 | + dataverse = Dataverse( |
| 142 | + server_url=base_url, |
| 143 | + api_token=api_token, |
| 144 | + ) |
| 145 | + |
| 146 | + # Act |
| 147 | + dataset = dataverse.create_dataset() |
| 148 | + dataset.license = CustomLicense( |
| 149 | + termsOfUse="This is a custom terms of use", |
| 150 | + confidentialityDeclaration="This is a custom confidentiality declaration", |
| 151 | + specialPermissions="This is a custom special permissions", |
| 152 | + restrictions="This is a custom restrictions", |
| 153 | + citationRequirements="This is a custom citation requirements", |
| 154 | + depositorRequirements="This is a custom depositor requirements", |
| 155 | + conditions="This is a custom conditions", |
| 156 | + disclaimer="This is a custom disclaimer", |
| 157 | + ) |
| 158 | + |
| 159 | + dataset.citation.title = "My dataset" |
| 160 | + dataset.citation.subject = ["Other"] |
| 161 | + dataset.citation.add_author(name="John Doe") |
| 162 | + dataset.citation.add_ds_description( |
| 163 | + value="This is a description of the dataset", |
| 164 | + date="2024", |
| 165 | + ) |
| 166 | + dataset.citation.add_dataset_contact( |
| 167 | + name="John Doe", |
| 168 | + email="john@doe.com", |
| 169 | + ) |
| 170 | + |
| 171 | + pid = dataset.upload(dataverse_name="root") |
| 172 | + |
| 173 | + # Re-fetch the dataset |
| 174 | + dataset = dataverse.load_dataset(pid) |
| 175 | + |
| 176 | + # Check the terms of use |
| 177 | + assert isinstance(dataset.license, CustomLicense) |
| 178 | + license = dataset.license |
| 179 | + assert license.terms_of_use == "This is a custom terms of use" |
| 180 | + assert license.special_permissions == "This is a custom special permissions" |
| 181 | + assert license.restrictions == "This is a custom restrictions" |
| 182 | + assert license.citation_requirements == "This is a custom citation requirements" |
| 183 | + assert license.conditions == "This is a custom conditions" |
| 184 | + assert license.disclaimer == "This is a custom disclaimer" |
| 185 | + assert ( |
| 186 | + license.confidentiality_declaration |
| 187 | + == "This is a custom confidentiality declaration" |
| 188 | + ) |
| 189 | + assert ( |
| 190 | + license.depositor_requirements == "This is a custom depositor requirements" |
| 191 | + ) |
| 192 | + |
| 193 | + @pytest.mark.integration |
133 | 194 | def test_tab_ingest_disabled( |
134 | 195 | self, |
135 | 196 | credentials, |
|
0 commit comments