Ejemplo n.º 1
0
def test_get_license_url_version():
    """The license URL method should return the expected URL for a license version"""
    assert "https://creativecommons.org/licenses/by/3.0" == licenses.get_license_url("by", "3.0")
    assert "https://creativecommons.org/licenses/by-sa/3.0" == licenses.get_license_url("by-sa", "3.0")
    assert "https://creativecommons.org/licenses/by-nc/3.0" == licenses.get_license_url("by-nc", "3.0")
    assert "https://creativecommons.org/licenses/by-nc-nd/3.0" == licenses.get_license_url("by-nc-nd", "3.0")
    assert "https://creativecommons.org/licenses/by-nc-sa/3.0" == licenses.get_license_url("by-nc-sa", "3.0")
Ejemplo n.º 2
0
def test_get_license_url_license():
    """The license URL method should return the expected URL for a license type"""
    assert "https://creativecommons.org/licenses/by/4.0" == licenses.get_license_url("by", "4.0")
    assert "https://creativecommons.org/licenses/by-sa/4.0" == licenses.get_license_url("by-sa", "4.0")
    assert "https://creativecommons.org/licenses/by-nc/4.0" == licenses.get_license_url("by-nc", "4.0")
    assert "https://creativecommons.org/licenses/by-nc-nd/4.0" == licenses.get_license_url("by-nc-nd", "4.0")
    assert "https://creativecommons.org/licenses/by-nc-sa/4.0" == licenses.get_license_url("by-nc-sa", "4.0")
Ejemplo n.º 3
0
def by_image():
    """Load an image in detail view, passing parameters by query string so that
    we can either load an image from an external provider or from our own datastore."""
    url = request.args.get('url')
    provider_url = request.args.get('provider_url')
    title = request.args.get('title')
    license = request.args.get('license')
    creator = request.args.get('creator')
    provider = request.args.get('provider')
    license_version = licenses.license_map_from_partners()[provider]['version']
    license_url = licenses.get_license_url(license, license_version)
    return render_template('detail.html',
                           url=url,
                           title=title,
                           provider_url=provider_url,
                           license=license,
                           license_url=license_url,
                           creator=creator)
Ejemplo n.º 4
0
def detail(identifier):
    """Get a detailed representation of an item in the ledger"""
    image = Image.query.filter_by(google_imageid=identifier).first()  # Eventually we'll want our own identifer here
    url = image.image_url
    provider_url = image.original_landing_url
    title = image.title
    provider = 'flickr'  # These images are Flickr-sourced, so treat this like a Flickr provider
    license_version = licenses.license_map_from_partners()[provider]['version']
    license = 'BY'  # This source contains only CC
    license_url = licenses.get_license_url(license, license_version)
    creator = image.author
    return render_template('detail.html',
                           image=image,
                           url=url,
                           title=title,
                           provider_url=provider_url,
                           license=license,
                           license_url=license_url,
                           creator=creator)
Ejemplo n.º 5
0
def test_get_license_url_pd_licenses():
    """The license URL method should return the correct public domain licenses regardless of version"""
    assert "https://creativecommons.org/publicdomain/zero/1.0" == licenses.get_license_url("cc0", "10.0")
    assert "https://creativecommons.org/publicdomain/mark/1.0" == licenses.get_license_url("pdm", "10.0")
Ejemplo n.º 6
0
def test_get_license_url_unknown_license():
    """The license URL method should return None if passed an unknown license"""
    assert licenses.get_license_url("FAKE", "3.0") is None
Ejemplo n.º 7
0
def test_get_license_url_no_license():
    """The license URL method should return an exception if not passed a license"""
    with pytest.raises(Exception) as exc:
        licenses.get_license_url(None, "3.0")
    assert 'No license' in str(exc.value)
Ejemplo n.º 8
0
def test_get_license_url_no_version():
    """The license URL method should return an exception if not passed a version"""
    with pytest.raises(Exception) as exc:
        licenses.get_license_url("by", None)
    assert 'No version' in str(exc.value)