def test_valid_full(): valid_full = { "title": "Creative Commons Attribution 4.0 International", "description": "A description", "link": "https://creativecommons.org/licenses/by/4.0/" } assert valid_full == RightsSchema().load(valid_full)
def test_invalid_vocab(): invalid_url = { "id": "cc-by-4.0", "link": "creativecommons.org/licenses/by/4.0/" } with pytest.raises(ValidationError): RightsSchema().load(invalid_url)
def test_valid_minimal_free_text(running_app): valid_minimal = { "title": { "en": "Creative Commons Attribution 4.0 International" }, } assert valid_minimal == RightsSchema().load(valid_minimal)
def test_invalid_url(): invalid_url = { "title": "Creative Commons Attribution 4.0 International", "description": "A description", "link": "creativecommons.org/licenses/by/4.0/" } with pytest.raises(ValidationError): data = RightsSchema().load(invalid_url)
def test_invalid_no_right(): invalid_no_right = { "link": "https://opensource.org/licenses/BSD-3-Clause", "identifier": "BSD-3", "scheme": "BSD-3" } with pytest.raises(ValidationError): data = RightsSchema().load(invalid_no_right)
def test_valid_full(): valid_full = { "rights": "Creative Commons Attribution 4.0 International", "scheme": "spdx", "identifier": "cc-by-4.0", "uri": "https://creativecommons.org/licenses/by/4.0/" } assert valid_full == RightsSchema().load(valid_full)
def test_invalid_structure(): invalid_structure = { "title": "Creative Commons Attribution 4.0 International", "description": {"en": "A description"}, "link": "https://creativecommons.org/licenses/by/4.0/" } with pytest.raises(ValidationError): RightsSchema().load(invalid_structure)
def test_invalid_id_and_title(): invalid_url = { "title": {"en": "Creative Commons Attribution 4.0 International"}, "description": {"en": "A description"}, "id": "cc-by-4.0", "link": "creativecommons.org/licenses/by/4.0/" } with pytest.raises(ValidationError): RightsSchema().load(invalid_url)
def test_invalid_extra_right(): invalid_extra = { "rights": "Creative Commons Attribution 4.0 International", "scheme": "spdx", "identifier": "cc-by-4.0", "uri": "https://creativecommons.org/licenses/by/4.0/", "extra": "field" } with pytest.raises(ValidationError): data = RightsSchema().load(invalid_extra)
def test_invalid_multiple_title(running_app): invalid_url = { "title": { "en": "Creative Commons Attribution 4.0 International", "es": "Creative Commons Attribution 4.0 International ES" }, "description": { "en": "A description" }, "link": "creativecommons.org/licenses/by/4.0/" } with pytest.raises(ValidationError): RightsSchema().load(invalid_url)
def test_valid_minimal(): valid_minimal = { "id": "cc-by-4.0", } assert valid_minimal == RightsSchema().load(valid_minimal)
def test_invalid_right(invalid_right): with pytest.raises(ValidationError): data = RightsSchema().load(invalid_right)
def test_valid_minimal(): valid_minimal = { "rights": "Copyright (C) 2020. All rights reserved.", } assert valid_minimal == RightsSchema().load(valid_minimal)
def test_valid_minimal_vocab(running_app): valid_minimal = { "id": "cc-by-4.0", } assert valid_minimal == RightsSchema().load(valid_minimal)