Ejemplo n.º 1
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'
Ejemplo n.º 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'
Ejemplo n.º 3
0
 def test_parent_of_a_non_leaf_node(self):
     assert URLPath('/a/b/c/').parent == '/a/b/'
Ejemplo n.º 4
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
Ejemplo n.º 5
0
 def test_is_leaf_node(self):
     assert URLPath('/a/b/c').is_leaf
     assert not URLPath('/a/b/c/').is_leaf
Ejemplo n.º 6
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'
Ejemplo n.º 7
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/'
Ejemplo n.º 8
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'
Ejemplo n.º 9
0
 def test_add_segment_encodes_slash_characters(self):
     assert URLPath('/a/b/c').add_segment('d/e') == '/a/b/c/d%2Fe'
Ejemplo n.º 10
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')
Ejemplo n.º 11
0
 def test_preserves_hash_of_the_original_string(self):
     assert hash(URLPath('/a/b/c')) == hash('/a/b/c')
Ejemplo n.º 12
0
 def test_root_always_returns_the_root_path(self):
     assert URLPath.root == '/'
     assert URLPath('/').root == '/'
     assert URLPath('/a/b/c').root == '/'
Ejemplo n.º 13
0
 def test_add_does_not_encode_slash_characters(self):
     assert URLPath('/a/b/c').add('d/e') == '/a/b/c/d/e'
Ejemplo n.º 14
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'
Ejemplo n.º 15
0
 def test_segments_decodes_percent_escapes(self):
     assert URLPath('/a%20b/c%2Fd/').segments == ('a b', 'c/d', '')
Ejemplo n.º 16
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'
Ejemplo n.º 17
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/'
Ejemplo n.º 18
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'
Ejemplo n.º 19
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/'
Ejemplo n.º 20
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'
Ejemplo n.º 21
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/'