Skip to content

test_license#

test_create_dataset_license_without_url_and_custom_url#

Should return Validation error.

Source code in tests/unit/apps/core/adapters/test_license.py
def test_create_dataset_license_without_url_and_custom_url():
    """Should return Validation error."""
    with pytest.raises(serializers.ValidationError) as error:
        ser = LicenseModelSerializer()
        ser.create({})
        assert "License needs url or custom_url, got None" in str(error.value)

test_create_dataset_license_with_custom_url#

Should automatically fill reference to use other license.

Source code in tests/unit/apps/core/adapters/test_license.py
def test_create_dataset_license_with_custom_url(license_reference_data):
    """Should automatically fill reference to use other license."""
    ser = LicenseModelSerializer()
    license = ser.create({"custom_url": "https://test.com"})
    assert license.reference.url == "http://uri.suomi.fi/codelist/fairdata/license/code/other"
    assert license.custom_url == "https://test.com"

test_create_dataset_license_with_non_existing_url#

Should return Validation error.

Source code in tests/unit/apps/core/adapters/test_license.py
def test_create_dataset_license_with_non_existing_url(license_reference_data):
    """Should return Validation error."""
    with pytest.raises(serializers.ValidationError) as error:
        ser = LicenseModelSerializer()
        ser.create({"url": "http://diipadaapa.co.uk"})
        assert "License not found http://diipadaapa.co.uk" in str(error.value)

test_update_dataset_license_with_invalid_url#

Should automatically fill reference to use other license.

Source code in tests/unit/apps/core/adapters/test_license.py
def test_update_dataset_license_with_invalid_url(license_reference_data):
    """Should automatically fill reference to use other license."""
    with pytest.raises(serializers.ValidationError) as error:
        ser = LicenseModelSerializer()
        license = ser.create({"custom_url": "https://test.com"})
        ser.update(license, {"url": "https://diipadaapa.com"})
        assert "License not found https://diipadaapa.com" in str(error.value)

test_update_dataset_license#

Should automatically fill reference to use other license.

Source code in tests/unit/apps/core/adapters/test_license.py
def test_update_dataset_license(license_reference_data):
    """Should automatically fill reference to use other license."""
    ser = LicenseModelSerializer()
    license = ser.create({"custom_url": "https://test.com"})
    updated = ser.update(license, {"custom_url": "https://diipadaapa.com"})
    assert updated.custom_url == "https://diipadaapa.com"