Beispiel #1
0
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)
Beispiel #2
0
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)
Beispiel #3
0
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)
Beispiel #4
0
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)
Beispiel #5
0
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)
Beispiel #6
0
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)
Beispiel #7
0
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)
Beispiel #8
0
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)
Beispiel #9
0
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)
Beispiel #10
0
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)
Beispiel #11
0
def test_valid_minimal():
    valid_minimal = {
        "id": "cc-by-4.0",
    }
    assert valid_minimal == RightsSchema().load(valid_minimal)
Beispiel #12
0
def test_invalid_right(invalid_right):
    with pytest.raises(ValidationError):
        data = RightsSchema().load(invalid_right)
Beispiel #13
0
def test_valid_minimal():
    valid_minimal = {
        "rights": "Copyright (C) 2020. All rights reserved.",
    }
    assert valid_minimal == RightsSchema().load(valid_minimal)
Beispiel #14
0
def test_valid_minimal_vocab(running_app):
    valid_minimal = {
        "id": "cc-by-4.0",
    }
    assert valid_minimal == RightsSchema().load(valid_minimal)