Esempio n. 1
0
def component_suites(request, resource=None, component=None, extra_element="", **kwargs):
    'Return part of a client-side component, served locally for some reason'

    get_params = request.GET.urlencode()
    if get_params and False:
        redone_url = static_path("dash/component/%s/%s%s?%s" %(component, extra_element, resource, get_params))
    else:
        resource, _fingerprint = check_fingerprint(resource)
        redone_url = static_path("dash/component/%s/%s%s" % (component, extra_element, resource))

    return HttpResponseRedirect(redirect_to=redone_url)
Esempio n. 2
0
def test_fingerprint():
    for resource in valid_resources:
        # The fingerprint matches expectations
        fingerprint = build_fingerprint(
            resource.get("path"),
            resource.get("version", version),
            resource.get("hash", hash_value),
        )
        assert fingerprint == resource.get("fingerprint")

        (original_path, has_fingerprint) = check_fingerprint(fingerprint)
        # The inverse operation returns that the fingerprint was valid
        # and the original path
        assert has_fingerprint
        assert original_path == resource.get("path")

    for resource in valid_fingerprints:
        (_, has_fingerprint) = check_fingerprint(resource)
        assert has_fingerprint, resource

    for resource in invalid_fingerprints:
        (_, has_fingerprint) = check_fingerprint(resource)
        assert not has_fingerprint, resource