Beispiel #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))
Beispiel #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)
Beispiel #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)
Beispiel #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)
Beispiel #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),
     )
Beispiel #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")
Beispiel #7
0
 def test_query_gen_type(self):
     test_url = Url("myurl.com").query(a=[0, 1])
     self.assertIsInstance(test_url._query_gen(), str)
Beispiel #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")
Beispiel #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")
Beispiel #10
0
 def test_netloc_equalto(self):
     test_url = Url("myurl.com")
     self.assertEqual(test_url.netloc, test_url.__hostname__)
Beispiel #11
0
 def test_page_gen_equalto(self):
     test_url = Url("myurl.com").page("HELLO")
     self.assertEqual(test_url._page_gen(), "/HELLO")
Beispiel #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")
Beispiel #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")
Beispiel #14
0
 def test_scheme_type(self):
     test_url = Url("")
     self.assertIsInstance(test_url.__scheme__, str)
Beispiel #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")
Beispiel #16
0
 def test_hostname_type(self):
     test_url = Url("")
     self.assertIsInstance(test_url.__hostname__, str)
Beispiel #17
0
 def test_fragement_type(self):
     test_url = Url("")
     self.assertIsInstance(test_url.__fragment__, str)
Beispiel #18
0
 def test_pagetrack_type(self):
     test_url = Url("")
     self.assertIsInstance(test_url.__pages__, list)
Beispiel #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")
Beispiel #20
0
 def test___query___type(self):
     test_url = Url("")
     self.assertIsInstance(test_url.__query__, OrderedDict)
Beispiel #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")
Beispiel #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"}))
Beispiel #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")
Beispiel #24
0
 def test_page_equalto(self):
     test_url = Url("myurl.com").page("HELLO")
     self.assertEqual(test_url.__pages__, ["HELLO"])
Beispiel #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")
Beispiel #26
0
 def test_path_equalto(self):
     test_url = Url("myurl.com").page("HELLO")
     self.assertEqual(test_url.path, test_url.url.path)
Beispiel #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")
Beispiel #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")
Beispiel #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"})
Beispiel #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")
Beispiel #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")
Beispiel #32
0
 def test_page_gen_type(self):
     test_url = Url("myurl.com").page("HELLO")
     self.assertIsInstance(test_url._page_gen(), str)
Beispiel #33
0
 def test_url_is_string_method(self):
     test_url = Url("myurl.com")
     self.assertIsInstance(str(test_url), str)
Beispiel #34
0
 def test_page_gen_equalto(self):
     test_url = Url("myurl.com").page("HELLO")
     self.assertEqual(test_url._page_gen(), "/HELLO")
Beispiel #35
0
 def test_page_gen_type(self):
     test_url = Url("myurl.com").page("HELLO")
     self.assertIsInstance(test_url._page_gen(), str)
Beispiel #36
0
 def test_query_gen_type(self):
     test_url = Url("myurl.com").query(a=[0, 1])
     self.assertIsInstance(test_url._query_gen(), str)
Beispiel #37
0
 def test_scheme_equalto(self):
     test_url = Url("myurl.com")
     self.assertEqual(test_url.schemes, test_url.__scheme__, "https")