Example #1
0
def test_url_with_different_scheme():
    final_url = URL('https://gemini.circumlunar.space/')
    assert str(final_url) == 'https://gemini.circumlunar.space/'
    assert final_url.protocol() == 'https://'
    assert final_url.host() == 'gemini.circumlunar.space'
    assert final_url.port() == 1965
    assert final_url.path() == '/'
    assert final_url.query() == ''
Example #2
0
def test_url_with_nonstandard_port():
    final_url = URL('gemini://gemini.circumlunar.space:80/')
    assert str(final_url) == 'gemini://gemini.circumlunar.space:80/'
    assert final_url.protocol() == 'gemini://'
    assert final_url.host() == 'gemini.circumlunar.space'
    assert final_url.port() == 80
    assert final_url.path() == '/'
    assert final_url.query() == ''
Example #3
0
def test_relative_path_url_with_trailing_slash_with_referer():
    final_url = URL('page1/', referer_url='gemini://gus.guru/')
    assert str(final_url) == 'gemini://gus.guru/page1/'
    assert final_url.protocol() == 'gemini://'
    assert final_url.host() == 'gus.guru'
    assert final_url.port() == 1965
    assert final_url.path() == '/page1/'
    assert final_url.query() == ''
Example #4
0
def test_relative_path_url_with_referer():
    final_url = URL('page1', referer_url='gemini://gus.guru/search/page2')
    assert str(final_url) == 'gemini://gus.guru/search/page1'
    assert final_url.protocol() == 'gemini://'
    assert final_url.host() == 'gus.guru'
    assert final_url.port() == 1965
    assert final_url.path() == '/search/page1'
    assert final_url.query() == ''
Example #5
0
def test_absolute_path_url():
    final_url = URL('/home', referer_url='gemini://gus.guru/search/page2')
    assert str(final_url) == 'gemini://gus.guru/home'
    assert final_url.protocol() == 'gemini://'
    assert final_url.host() == 'gus.guru'
    assert final_url.port() == 1965
    assert final_url.path() == '/home'
    assert final_url.query() == ''
Example #6
0
def test_url_with_path():
    final_url = URL('gemini://gemini.circumlunar.space/test/path.gmi')
    assert str(final_url) == 'gemini://gemini.circumlunar.space/test/path.gmi'
    assert final_url.protocol() == 'gemini://'
    assert final_url.host() == 'gemini.circumlunar.space'
    assert final_url.port() == 1965
    assert final_url.path() == '/test/path.gmi'
    assert final_url.query() == ''
Example #7
0
def test_url_without_designation():
    final_url = URL('gemini.circumlunar.space/test')
    assert str(final_url) == 'gemini://gemini.circumlunar.space/test'
    assert final_url.protocol() == 'gemini://'
    assert final_url.host() == ''
    assert final_url.port() == 1965
    assert final_url.path() == 'gemini.circumlunar.space/test'
    assert final_url.query() == ''
Example #8
0
def test_standard_gemini_url():
    final_url = URL('gemini://gemini.circumlunar.space/')
    assert str(final_url) == 'gemini://gemini.circumlunar.space/'
    assert final_url.protocol() == 'gemini://'
    assert final_url.host() == 'gemini.circumlunar.space'
    assert final_url.port() == 1965
    assert final_url.path() == '/'
    assert final_url.query() == ''
Example #9
0
 def test_url_with_different_scheme(self):
     final_url = URL('https://gemini.circumlunar.space/')
     self.assertEqual(str(final_url), 'https://gemini.circumlunar.space/')
     self.assertEqual(final_url.protocol(), 'https://')
     self.assertEqual(final_url.host(), 'gemini.circumlunar.space')
     self.assertEqual(final_url.port(), 1965)
     self.assertEqual(final_url.path(), '/')
     self.assertEqual(final_url.query(), '')
Example #10
0
 def test_url_with_no_path(self):
     final_url = URL('gemini://gemini.circumlunar.space')
     self.assertEqual(str(final_url), 'gemini://gemini.circumlunar.space')
     self.assertEqual(final_url.protocol(), 'gemini://')
     self.assertEqual(final_url.host(), 'gemini.circumlunar.space')
     self.assertEqual(final_url.port(), 1965)
     self.assertEqual(final_url.path(), '')
     self.assertEqual(final_url.query(), '')
Example #11
0
 def test_relative_path_url_with_trailing_slash(self):
     final_url = URL('page1/', referer_url='gemini://gus.guru/')
     self.assertEqual(str(final_url), 'gemini://gus.guru/page1/')
     self.assertEqual(final_url.protocol(), 'gemini://')
     self.assertEqual(final_url.host(), 'gus.guru')
     self.assertEqual(final_url.port(), 1965)
     self.assertEqual(final_url.path(), '/page1/')
     self.assertEqual(final_url.query(), '')
Example #12
0
 def test_relative_path_url(self):
     final_url = URL('page1', referer_url='gemini://gus.guru/search/page2')
     self.assertEqual(str(final_url), 'gemini://gus.guru/search/page1')
     self.assertEqual(final_url.protocol(), 'gemini://')
     self.assertEqual(final_url.host(), 'gus.guru')
     self.assertEqual(final_url.port(), 1965)
     self.assertEqual(final_url.path(), '/search/page1')
     self.assertEqual(final_url.query(), '')
Example #13
0
 def test_url_with_nonstandard_port(self):
     final_url = URL('gemini://gemini.circumlunar.space:80/')
     self.assertEqual(str(final_url),
                      'gemini://gemini.circumlunar.space:80/')
     self.assertEqual(final_url.protocol(), 'gemini://')
     self.assertEqual(final_url.host(), 'gemini.circumlunar.space')
     self.assertEqual(final_url.port(), 80)
     self.assertEqual(final_url.path(), '/')
     self.assertEqual(final_url.query(), '')
Example #14
0
 def test_url_without_scheme(self):
     final_url = URL('//gus.guru/',
                     referer_url='gemini://gemini.circumlunar.space/')
     self.assertEqual(str(final_url), 'gemini://gus.guru/')
     self.assertEqual(final_url.protocol(), 'gemini://')
     self.assertEqual(final_url.host(), 'gus.guru')
     self.assertEqual(final_url.port(), 1965)
     self.assertEqual(final_url.path(), '/')
     self.assertEqual(final_url.query(), '')
Example #15
0
def test_url_without_scheme_with_referer():
    final_url = URL('//gus.guru/',
                    referer_url='gemini://gemini.circumlunar.space/')
    assert str(final_url) == 'gemini://gus.guru/'
    assert final_url.protocol() == 'gemini://'
    assert final_url.host() == 'gus.guru'
    assert final_url.port() == 1965
    assert final_url.path() == '/'
    assert final_url.query() == ''
Example #16
0
 def test_url_with_convoluted_path(self):
     final_url = URL(
         'gemini://gemini.circumlunar.space/test/./test2/../path.gmi')
     self.assertEqual(str(final_url),
                      'gemini://gemini.circumlunar.space/test/path.gmi')
     self.assertEqual(final_url.protocol(), 'gemini://')
     self.assertEqual(final_url.host(), 'gemini.circumlunar.space')
     self.assertEqual(final_url.port(), 1965)
     self.assertEqual(final_url.path(), '/test/path.gmi')
     self.assertEqual(final_url.query(), '')
Example #17
0
 def test_url_with_query(self):
     final_url = URL(
         'gemini://gemini.circumlunar.space/test/path.gmi?user=name')
     self.assertEqual(
         str(final_url),
         'gemini://gemini.circumlunar.space/test/path.gmi?user=name')
     self.assertEqual(final_url.protocol(), 'gemini://')
     self.assertEqual(final_url.host(), 'gemini.circumlunar.space')
     self.assertEqual(final_url.port(), 1965)
     self.assertEqual(final_url.path(), '/test/path.gmi')
     self.assertEqual(final_url.query(), 'user=name')