示例#1
0
def test_passive_app(passive_app, mock_aioresponse, r_package):
    package_path = URLPath("/src/contrib/latest_0.7.5.tar.gz")
    remote_path = passive_app.config.UPSTREAM_CRAN_SERVER_URL.add_path(
        package_path)
    mock_aioresponse.get(remote_path, status=200, body=r_package)
    passive_app.test_client.get(package_path, allow_redirects=False)
    assert len(mock_aioresponse.requests) == 0
示例#2
0
 def test_relative_on_a_non_leaf_node(self):
     path = URLPath('/a/b/c/')
     assert path.relative('.') == '/a/b/c/'
     assert path.relative('d') == '/a/b/c/d'
     assert path.relative('..') == '/a/b/'
     assert path.relative('../d') == '/a/b/d'
     assert path.relative('/') == '/'
     assert path.relative('/d') == '/d'
示例#3
0
 def test_relative_on_a_leaf_node(self):
     path = URLPath(u'/a/b/c')
     assert path.relative(u'.') == u'/a/b/'
     assert path.relative(u'd') == u'/a/b/d'
     assert path.relative(u'..') == u'/a/'
     assert path.relative(u'../d') == u'/a/d'
     assert path.relative(u'/') == u'/'
     assert path.relative(u'/d') == u'/d'
示例#4
0
def test_get_single_binary_package(app, mock_aioresponse, r_package_binary):
    package_path = URLPath("/src/contrib/later_0.7.5.tar.gz")
    remote_path = app.config.UPSTREAM_CRAN_SERVER_URL.add_path(package_path)
    mock_aioresponse.get(remote_path, status=200, body=r_package_binary)

    request, response = app.test_client.get(package_path,
                                            allow_redirects=False)
    assert response.status == 302
    assert response.headers["location"] == remote_path
    assert not app.compile_queue.empty()
示例#5
0
def url_join(base, *paths):
    """
    Append `paths` to `base`. Path resets on each absolute path.

    Like os.path.join, but for URLs.
    """
    if not hasattr(base, 'add_path'):
        base = URLObject(base)

    for path in paths:
        path = URLPath(path)
        base = base.add_path(path)
    return base
示例#6
0
 def test_relative_on_a_non_leaf_node(self):
     path = URLPath('/a/b/c/')
     assert path.relative('.') == '/a/b/c/'
     assert path.relative('d') == '/a/b/c/d'
     assert path.relative('..') == '/a/b/'
     assert path.relative('../d') == '/a/b/d'
     assert path.relative('/') == '/'
     assert path.relative('/d') == '/d'
示例#7
0
 def test_relative_on_a_non_leaf_node(self):
     path = URLPath(u"/a/b/c/")
     assert path.relative(u".") == u"/a/b/c/"
     assert path.relative(u"d") == u"/a/b/c/d"
     assert path.relative(u"..") == u"/a/b/"
     assert path.relative(u"../d") == u"/a/b/d"
     assert path.relative(u"/") == u"/"
     assert path.relative(u"/d") == u"/d"
示例#8
0
def test_get_packages(app, mock_aioresponse):
    packages_index_path = URLPath("/src/contrib/PACKAGES")
    remote_path = app.config.UPSTREAM_CRAN_SERVER_URL.add_path(
        packages_index_path)
    mock_aioresponse.get(remote_path, status=200)

    request, response = app.test_client.get(packages_index_path)

    assert response.status == 200
    reqs = {k: v for k, v in mock_aioresponse.requests}

    # check that remote request was made
    remote_req = reqs["GET"]
    assert len(reqs) == 1

    assert remote_req.path_qs == packages_index_path
示例#9
0
 def test_add_encodes_non_ascii_and_reserved_characters(self):
     assert URLPath('/a/b/c').add(
         u('d /\N{LATIN SMALL LETTER E WITH ACUTE}')
     ) == '/a/b/c/d%20/%C3%A9'
示例#10
0
 def test_preserves_equality_with_original_string(self):
     assert URLPath('/a/b/c') == '/a/b/c'
     assert URLPath('a/b/c') == 'a/b/c'
示例#11
0
 def test_add_segment_adds_path_segments_to_a_path(self):
     assert URLPath('').add_segment('a') == 'a'
     assert URLPath('/').add_segment('a') == '/a'
     assert URLPath('/a/b/c').add_segment('d') == '/a/b/c/d'
     assert URLPath('/a/b/c').add_segment('d/') == '/a/b/c/d%2F'
示例#12
0
 def test_parent_of_a_non_leaf_node(self):
     assert URLPath('/a/b/c/').parent == '/a/b/'
示例#13
0
 def test_is_leaf_node(self):
     assert URLPath('/a/b/c').is_leaf
     assert not URLPath('/a/b/c/').is_leaf
示例#14
0
 def test_join_segments_can_create_relative_paths(self):
     assert URLPath.join_segments(('a', 'b', 'c'),
                                  absolute=False) == 'a/b/c'
     assert URLPath.join_segments(('a', 'b', 'c', ''),
                                  absolute=False) == 'a/b/c/'
示例#15
0
 def test_join_segments_encodes_non_ascii_and_special_characters_including_slash(self):
     URLPath.join_segments((u'a b', u'd/é')) == u'/a%20b/d%2F%C3%A9'
示例#16
0
 def test_join_segments_can_create_relative_paths(self):
     URLPath.join_segments((u'a', u'b', u'c'), absolute=False) == u'a/b/c'
     URLPath.join_segments((u'a', u'b', u'c', u''), absolute=False) == u'a/b/c/'
示例#17
0
 def test_join_segments_joins_segments_into_a_single_path(self):
     URLPath.join_segments((u'a', u'b', u'c')) == u'/a/b/c'
     URLPath.join_segments((u'a', u'b', u'c', u'')) == u'/a/b/c/'
示例#18
0
 def test_join_segments_encodes_non_ascii_and_special_characters_including_slash(self):
     URLPath.join_segments((u"a b", u"d/é")) == u"/a%20b/d%2F%C3%A9"
示例#19
0
 def test_join_segments_can_create_relative_paths(self):
     URLPath.join_segments((u"a", u"b", u"c"), absolute=False) == u"a/b/c"
     URLPath.join_segments((u"a", u"b", u"c", u""), absolute=False) == u"a/b/c/"
示例#20
0
 def test_join_segments_joins_segments_into_a_single_path(self):
     URLPath.join_segments((u"a", u"b", u"c")) == u"/a/b/c"
     URLPath.join_segments((u"a", u"b", u"c", u"")) == u"/a/b/c/"
示例#21
0
 def test_segments_decodes_percent_escapes(self):
     assert URLPath('/a%20b/c%2Fd/').segments == ('a b', 'c/d', '')
示例#22
0
 def test_join_segments_joins_segments_into_a_single_path(self):
     assert URLPath.join_segments(('a', 'b', 'c')) == '/a/b/c'
     assert URLPath.join_segments(('a', 'b', 'c', '')) == '/a/b/c/'
示例#23
0
 def test_parent_of_a_leaf_node(self):
     assert URLPath(u'/a/b/c').parent == u'/a/b/'
示例#24
0
 def test_join_segments_encodes_non_ascii_and_special_characters_including_slash(
         self):
     assert URLPath.join_segments((
         'a b',
         u('d/\N{LATIN SMALL LETTER E WITH ACUTE}'))) == '/a%20b/d%2F%C3%A9'
示例#25
0
 def test_join_segments_can_create_relative_paths(self):
     assert URLPath.join_segments(('a', 'b', 'c'), absolute=False) == 'a/b/c'
     assert URLPath.join_segments(('a', 'b', 'c', ''), absolute=False) == 'a/b/c/'
示例#26
0
 def test_is_relative_equals_not_is_absolute(self):
     assert URLPath('a/b/c').is_relative
     assert not URLPath('/a/b/c').is_relative
     assert not URLPath('a/b/c').is_absolute
     assert URLPath('/a/b/c').is_absolute
示例#27
0
 def test_add_encodes_non_ascii_and_reserved_characters(self):
     assert URLPath(u'/a/b/c').add(u'd /é') == u'/a/b/c/d%20/%C3%A9'
示例#28
0
 def test_join_segments_joins_segments_into_a_single_path(self):
     assert URLPath.join_segments(('a', 'b', 'c')) == '/a/b/c'
     assert URLPath.join_segments(('a', 'b', 'c', '')) == '/a/b/c/'
示例#29
0
 def test_root_always_returns_the_root_path(self):
     assert URLPath.root == '/'
     assert URLPath('/').root == '/'
     assert URLPath('/a/b/c').root == '/'
示例#30
0
 def test_add_segment_encodes_slash_characters(self):
     assert URLPath('/a/b/c').add_segment('d/e') == '/a/b/c/d%2Fe'
示例#31
0
 def test_preserves_hash_of_the_original_string(self):
     assert hash(URLPath('/a/b/c')) == hash('/a/b/c')
示例#32
0
 def test_add_concatenates_whole_paths(self):
     assert URLPath('').add('a') == 'a'
     assert URLPath('/').add('a') == '/a'
     assert URLPath('/a/b/c').add('d') == '/a/b/c/d'
     assert URLPath('/a/b/c').add('d/') == '/a/b/c/d/'
     assert URLPath('/a/b/c').add('d/e/f') == '/a/b/c/d/e/f'
示例#33
0
 def test_segments_breaks_the_path_into_segments(self):
     assert URLPath('/a/b/c').segments == ('a', 'b', 'c')
     assert URLPath('/a/b/c/').segments == ('a', 'b', 'c', '')
     assert URLPath('a/b/c').segments == ('a', 'b', 'c')
示例#34
0
 def test_add_does_not_encode_slash_characters(self):
     assert URLPath('/a/b/c').add('d/e') == '/a/b/c/d/e'
示例#35
0
 def test_join_segments_encodes_non_ascii_and_special_characters_including_slash(self):
     assert URLPath.join_segments(('a b', u('d/\N{LATIN SMALL LETTER E WITH ACUTE}'))) == '/a%20b/d%2F%C3%A9'