Пример #1
0
def test_library_url_hashing_norecompute(tmpdir):
    foo = Library('foo', tmpdir.strpath)

    needed = NeededResources(versioning=True, recompute_hashes=False)

    url = needed.library_url(foo)

    # now create a file
    resource = tmpdir.join('test.js')
    resource.write('/* test */')

    # since we're not re-computing hashes, the hash in the URL won't change
    assert needed.library_url(foo) == url
Пример #2
0
def test_library_url_hashing_norecompute(tmpdir):
    foo = Library('foo', tmpdir.strpath)

    needed = NeededResources(versioning=True, recompute_hashes=False)

    url = needed.library_url(foo)

    # now create a file
    resource = tmpdir.join('test.js')
    resource.write('/* test */')

    # since we're not re-computing hashes, the hash in the URL won't change
    assert needed.library_url(foo) == url
Пример #3
0
def test_library_url_base_url():
    foo = Library('foo', '')

    needed = NeededResources(base_url="http://example.com/something")

    assert (needed.library_url(foo) ==
            'http://example.com/something/fanstatic/foo')
Пример #4
0
def test_library_url_version_hashing(tmpdir):
    foo = Library('foo', tmpdir.strpath)

    needed = NeededResources(versioning=True)
    url = needed.library_url(foo)
    assert re.match('/fanstatic/foo/:version:[0-9T:.-]*$', url)

    # The md5 based version URL is available through the
    # `versioning_use_md5` parameter:
    needed = NeededResources(versioning=True, versioning_use_md5=True)
    md5_url = needed.library_url(foo)
    assert url != md5_url

    # If the Library defines a version, the version is used.
    bar = Library('bar', '', version='1')
    assert needed.library_url(bar) == '/fanstatic/bar/:version:1'
Пример #5
0
def test_library_url_version_hashing(tmpdir):
    foo = Library('foo', tmpdir.strpath)

    needed = NeededResources(versioning=True)
    url = needed.library_url(foo)
    assert re.match('/fanstatic/foo/:version:[0-9T:.-]*$', url)

    # The md5 based version URL is available through the
    # `versioning_use_md5` parameter:
    needed = NeededResources(versioning=True, versioning_use_md5=True)
    md5_url = needed.library_url(foo)
    assert url != md5_url

    # If the Library defines a version, the version is used.
    bar = Library('bar', '', version='1')
    assert needed.library_url(bar) == '/fanstatic/bar/:version:1'
Пример #6
0
def test_library_url_base_url():
    foo = Library('foo', '')

    needed = NeededResources(base_url="http://example.com/something")

    assert (needed.library_url(foo) ==
            'http://example.com/something/fanstatic/foo')
Пример #7
0
def test_library_url_script_name_base_url():
    foo = Library('foo', '')
    needed = NeededResources(script_name='/root',
                             base_url="http://example.com/something")

    # base_url is set so script_name should be ignored
    assert (needed.library_url(foo) ==
            'http://example.com/something/fanstatic/foo')
Пример #8
0
def test_library_url_script_name_base_url():
    foo = Library('foo', '')
    needed = NeededResources(
        script_name='/root', base_url="http://example.com/something")

    # base_url is set so script_name should be ignored
    assert (needed.library_url(foo) ==
            'http://example.com/something/fanstatic/foo')
Пример #9
0
def test_library_url_hashing_recompute(tmpdir):
    foo = Library('foo', tmpdir.strpath)

    needed = NeededResources(versioning=True, recompute_hashes=True)

    url = needed.library_url(foo)

    # now create a file
    resource = tmpdir.join('test.js')

    time.sleep(0.02)
    # Sleep extra long on filesystems that report in seconds
    # instead of milliseconds.
    if os.path.getmtime(os.curdir).is_integer():
        time.sleep(1)
    resource.write('/* test */')

    # the hash is recalculated now, so it changes
    assert needed.library_url(foo) != url
Пример #10
0
def test_library_url_hashing_recompute(tmpdir):
    foo = Library('foo', tmpdir.strpath)

    needed = NeededResources(versioning=True, recompute_hashes=True)

    url = needed.library_url(foo)

    # now create a file
    resource = tmpdir.join('test.js')

    time.sleep(0.02)
    # Sleep extra long on filesystems that report in seconds
    # instead of milliseconds.
    if os.path.getmtime(os.curdir).is_integer():
        time.sleep(1)
    resource.write('/* test */')

    # the hash is recalculated now, so it changes
    assert needed.library_url(foo) != url
Пример #11
0
def test_library_url_with_url_caching(tmpdir):
    foo = Library('foo', tmpdir.strpath)

    needed = NeededResources(versioning=True, recompute_hashes=True)

    url = needed.library_url(foo)

    # now create a file
    resource = tmpdir.join('test.js')

    time.sleep(0.5)
    # Sleep extra long on filesystems that report in seconds
    # instead of milliseconds.
    if os.path.getmtime(os.curdir).is_integer():
        time.sleep(1)
    resource.write('/* test */')

    # The url is cached on the needed resources object.
    assert needed.library_url(foo) == url
Пример #12
0
def test_library_url_publisher_signature():
    foo = Library('foo', '')

    needed = NeededResources(publisher_signature='waku')

    assert needed.library_url(foo) == '/waku/foo'
Пример #13
0
def test_library_url_script_name():
    foo = Library('foo', '')
    needed = NeededResources(script_name='/root')
    assert needed.library_url(foo) == '/root/fanstatic/foo'
Пример #14
0
def test_library_url_default_publisher_signature():
    foo = Library('foo', '')

    needed = NeededResources()

    assert needed.library_url(foo) == '/fanstatic/foo'
Пример #15
0
def test_library_url_publisher_signature():
    foo = Library('foo', '')

    needed = NeededResources(publisher_signature='waku')

    assert needed.library_url(foo) == '/waku/foo'
Пример #16
0
def test_library_url_default_publisher_signature():
    foo = Library('foo', '')

    needed = NeededResources()

    assert needed.library_url(foo) == '/fanstatic/foo'
Пример #17
0
def test_library_url_script_name():
    foo = Library('foo', '')
    needed = NeededResources(script_name='/root')
    assert needed.library_url(foo) == '/root/fanstatic/foo'