Exemplo n.º 1
0
 def test_url_unurlparse_equalto(self):
     try:
         from urlparse import urlunparse  #PY2
     except ImportError:
         from urllib.parse import urlunparse  #PY3
     test_url = Url("myurl.com")
     self.assertEqual(
         urlunparse((test_url.__scheme__, test_url.__hostname__,
                     test_url._page_gen(), "", test_url._query_gen(),
                     test_url.__fragment__)), str(test_url))
Exemplo n.º 2
0
def gen_url(api, shards, version, API_URL=API_URL):
    if not api[0] == "world":
        url = Url(API_URL).query(**({api[0]: api[1]}))
    else:
        url = Url(API_URL)
    if shards:
        shard_package = tuple(shard_generator(shards))
        if shard_package:
            url.query(q=shard_package)
        url.query(**shard_object_extract(shards))
    if version:
        url.query(v=version)
    return str(url)
Exemplo n.º 3
0
 def test_url_urlparse_equalto(self):
     try:
         from urlparse import urlparse  #PY2
     except ImportError:
         from urllib.parse import urlparse  #PY3
     test_url = Url("myurl.com")
     self.assertEqual(urlparse(str(test_url)), test_url.url)
Exemplo n.º 4
0
 def get_url(self):
     if not self.type[0] == "world":
         url = Url(API_URL).query(**({self.type[0]: self.type[1]}))
     else:
         url = Url(API_URL)
     if self.shard:
         url.query(q=tuple(shard_generator(self.shard)))
         url.query(
             **shard_object_extract(self.shard))
     if self.version:
         url.query(v=self.version)
     return str(url)
Exemplo n.º 5
0
 def test_url_unurlparse_equalto(self):
     try:
         from urlparse import urlunparse  # PY2
     except ImportError:
         from urllib.parse import urlunparse  # PY3
     test_url = Url("myurl.com")
     self.assertEqual(
         urlunparse(
             (
                 test_url.__scheme__,
                 test_url.__hostname__,
                 test_url._page_gen(),
                 "",
                 test_url._query_gen(),
                 test_url.__fragment__,
             )
         ),
         str(test_url),
     )
Exemplo n.º 6
0
 def test_query_gen_equalto(self):
     test_url = Url("myurl.com").query(a=[0, 1])
     self.assertEqual(test_url._query_gen(), "a=0+1")
Exemplo n.º 7
0
 def test_query_gen_type(self):
     test_url = Url("myurl.com").query(a=[0, 1])
     self.assertIsInstance(test_url._query_gen(), str)
Exemplo n.º 8
0
 def test_url_scheme(self):
     test_url = Url("myurl.com")
     self.assertEqual(str(test_url), "https://myurl.com")
     test_url.scheme("http")
     self.assertEqual(str(test_url), "http://myurl.com")
Exemplo n.º 9
0
 def test_url_page(self):
     test_url = Url("myurl.com").page("HELLO")
     self.assertEqual(str(test_url), "https://myurl.com/HELLO")
     test_url.page("WORLD")
     self.assertEqual(str(test_url), "https://myurl.com/HELLO/WORLD")
Exemplo n.º 10
0
 def test_netloc_equalto(self):
     test_url = Url("myurl.com")
     self.assertEqual(test_url.netloc, test_url.__hostname__)
Exemplo n.º 11
0
 def test_page_gen_equalto(self):
     test_url = Url("myurl.com").page("HELLO")
     self.assertEqual(test_url._page_gen(), "/HELLO")
Exemplo n.º 12
0
 def test_query_gen_equalto(self):
     test_url = Url("myurl.com").query(a=[0, 1])
     self.assertEqual(test_url._query_gen(), "a=0+1")
Exemplo n.º 13
0
 def test_url_query_repeat_queary(self):
     test_url = Url("myurl.com").query(a=2).query(a=1)
     self.assertEqual(str(test_url), "https://myurl.com?a=1")
Exemplo n.º 14
0
 def test_scheme_type(self):
     test_url = Url("")
     self.assertIsInstance(test_url.__scheme__, str)
Exemplo n.º 15
0
 def test_url_query_single_query(self):
     test_url = Url("myurl.com").query(a=1)
     self.assertEqual(str(test_url), "https://myurl.com?a=1")
Exemplo n.º 16
0
 def test_hostname_type(self):
     test_url = Url("")
     self.assertIsInstance(test_url.__hostname__, str)
Exemplo n.º 17
0
 def test_fragement_type(self):
     test_url = Url("")
     self.assertIsInstance(test_url.__fragment__, str)
Exemplo n.º 18
0
 def test_pagetrack_type(self):
     test_url = Url("")
     self.assertIsInstance(test_url.__pages__, list)
Exemplo n.º 19
0
 def test_url_query_double_query(self):
     test_url = Url("myurl.com").query(a=1).query(b=10)
     self.assertEqual(str(test_url), "https://myurl.com?a=1&b=10")
Exemplo n.º 20
0
 def test___query___type(self):
     test_url = Url("")
     self.assertIsInstance(test_url.__query__, OrderedDict)
Exemplo n.º 21
0
 def test_url_page(self):
     test_url = Url("myurl.com").page("HELLO")
     self.assertEqual(str(test_url), "https://myurl.com/HELLO")
     test_url.page("WORLD")
     self.assertEqual(str(test_url), "https://myurl.com/HELLO/WORLD")
Exemplo n.º 22
0
 def test___query___equalto(self):
     test_url = Url("myurl.com").query(a=[0, 1])
     self.assertEqual(test_url.__query__, OrderedDict({"a": "0+1"}))
Exemplo n.º 23
0
 def test_url_hostname(self):
     test_url = Url("myurl.com")
     self.assertEqual(str(test_url), "https://myurl.com")
     test_url.hostname("mynewurl.com")
     self.assertEqual(str(test_url), "https://mynewurl.com")
Exemplo n.º 24
0
 def test_page_equalto(self):
     test_url = Url("myurl.com").page("HELLO")
     self.assertEqual(test_url.__pages__, ["HELLO"])
Exemplo n.º 25
0
 def test_url_scheme(self):
     test_url = Url("myurl.com")
     self.assertEqual(str(test_url), "https://myurl.com")
     test_url.scheme("http")
     self.assertEqual(str(test_url), "http://myurl.com")
Exemplo n.º 26
0
 def test_path_equalto(self):
     test_url = Url("myurl.com").page("HELLO")
     self.assertEqual(test_url.path, test_url.url.path)
Exemplo n.º 27
0
 def test_fragment_scheme(self):
     test_url = Url("myurl.com").fragment("file1")
     self.assertEqual(str(test_url), "https://myurl.com#file1")
     test_url.fragment("file2")
     self.assertEqual(str(test_url), "https://myurl.com#file2")
Exemplo n.º 28
0
 def test_url_hostname(self):
     test_url = Url("myurl.com")
     self.assertEqual(str(test_url), "https://myurl.com")
     test_url.hostname("mynewurl.com")
     self.assertEqual(str(test_url), "https://mynewurl.com")
Exemplo n.º 29
0
 def test_url___query___multi_query(self):
     test_url = Url("myurl.com").query(a="TEST", b="TEST")
     self.assertEqual(dict(test_url.__query__), {"a": "TEST", "b": "TEST"})
Exemplo n.º 30
0
 def test_fragment_scheme(self):
     test_url = Url("myurl.com").fragment("file1")
     self.assertEqual(str(test_url), "https://myurl.com#file1")
     test_url.fragment("file2")
     self.assertEqual(str(test_url), "https://myurl.com#file2")
Exemplo n.º 31
0
 def test_url_query_list(self):
     test_url = Url("myurl.com").query(a=[0, 1])
     self.assertEqual(str(test_url), "https://myurl.com?a=0+1")
Exemplo n.º 32
0
 def test_page_gen_type(self):
     test_url = Url("myurl.com").page("HELLO")
     self.assertIsInstance(test_url._page_gen(), str)
Exemplo n.º 33
0
 def test_url_is_string_method(self):
     test_url = Url("myurl.com")
     self.assertIsInstance(str(test_url), str)
Exemplo n.º 34
0
 def test_page_gen_equalto(self):
     test_url = Url("myurl.com").page("HELLO")
     self.assertEqual(test_url._page_gen(), "/HELLO")
Exemplo n.º 35
0
 def test_page_gen_type(self):
     test_url = Url("myurl.com").page("HELLO")
     self.assertIsInstance(test_url._page_gen(), str)
Exemplo n.º 36
0
 def test_query_gen_type(self):
     test_url = Url("myurl.com").query(a=[0, 1])
     self.assertIsInstance(test_url._query_gen(), str)
Exemplo n.º 37
0
 def test_scheme_equalto(self):
     test_url = Url("myurl.com")
     self.assertEqual(test_url.schemes, test_url.__scheme__, "https")