Example #1
0
 def setUp(self):
     self.unicode_param = 'значение'
     # Python 2.6 requires bytes for quote
     self.urlencoded_param = quote(self.unicode_param.encode('utf8'))
     url = 'http://www.google.com/blog/article/1?q=' + self.urlencoded_param
     self.ascii_url = URL.from_string(url.encode('ascii'))
     # django request.get_full_path() returns url as unicode
     self.unicode_url = URL.from_string(url)
Example #2
0
 def setUp(self):
     self.unicode_param = 'значение'
     # Python 2.6 requires bytes for quote
     self.urlencoded_param = quote(self.unicode_param.encode('utf8'))
     url = 'http://www.google.com/blog/article/1?q=' + self.urlencoded_param
     self.ascii_url = URL.from_string(url.encode('ascii'))
     # django request.get_full_path() returns url as unicode
     self.unicode_url = URL.from_string(url)
Example #3
0
 def assertIsRedirect(self, response, expected_url=None):
     self.assertTrue(
         response.status_code in (http_client.FOUND,
                                  http_client.MOVED_PERMANENTLY))
     if expected_url:
         location = URL.from_string(response['Location'])
         self.assertEqual(expected_url, location.path())
 def perform_action(self):
     basket = Mock()
     basket.id = 1
     basket.total_incl_tax = D('200')
     basket.all_lines = Mock(return_value=[])
     methods = [Free()]
     url_str = get_paypal_url(basket, methods)
     self.url = URL.from_string(url_str)
Example #5
0
    def test_missing_shipping_address(self):
        from paypal.express.views import RedirectView
        with patch.object(RedirectView,
                          'as_payment_method') as as_payment_method:
            as_payment_method.return_value = True

            url = reverse('paypal-redirect')
            self.add_product_to_basket()
            response = self.client.get(url)
            self.assertEqual(reverse('checkout:shipping-address'),
                             URL.from_string(response['Location']).path())
 def perform_action(self):
     basket = Mock()
     basket.id = 1
     basket.total_incl_tax = D('200')
     basket.all_lines = Mock(return_value=[])
     basket.offer_discounts = []
     basket.voucher_discounts = []
     basket.shipping_discounts = []
     methods = [Free()]
     url_str = get_paypal_url(basket, methods, paypal_params=self.paypal_params)
     self.url = URL.from_string(url_str)
 def perform_action(self):
     basket = Mock()
     basket.id = 1
     basket.total_incl_tax = D('200')
     basket.all_lines = Mock(return_value=[])
     basket.offer_discounts = []
     basket.voucher_discounts = []
     basket.shipping_discounts = []
     methods = [Free()]
     url_str = get_paypal_url(basket, methods)
     self.url = URL.from_string(url_str)
    def test_missing_shipping_address(self):
        from paypal.express.views import RedirectView
        with patch.object(RedirectView, 'as_payment_method') as as_payment_method:
            as_payment_method.return_value = True

            url = reverse('paypal-redirect')
            self.add_product_to_basket()
            response = self.client.get(url)
            self.assertEqual(
                reverse('checkout:shipping-address'),
                URL.from_string(response['Location']).path()
            )
Example #9
0
def process_url(link: str) -> Tuple:
    """Выводим мета-информацию о ссылке

    Args:
        link (str): Ссылка

    Returns:
        Tuple: Мета-информация:
            - Тип домена
            - Ссылка для сохранения в БД
    """
    url = URL.from_string(link)
    if 'vk.com' in url.host():
        if 'public' in url.path_segment(0):
            # id = url.path_segment(0).split('public')[1]
            # id = -1 * int(id)
            type = 'vk_owner'
        elif 'club' in url.path_segment(0):
            # id = url.path_segment(0).split('club')[1]
            # id = -1 * int(id)
            type = 'vk_owner'
        else:
            type = 'vk_domain'
            # id = url.path_segment(0)
        return type, link
    elif 'ok.ru' in url.host():
        return 'odnoklassniki_domain', link
    elif 'twitter.com' in url.host():
        return 'twi', link
    elif 'instagram.com' in url.host():
        return 'insta', link
    elif 'youtube.com' in url.host():
        return 'youtube', link
    elif 'facebook.com' in url.host():
        return 'facebook', link
    else:
        return 'site', url.scheme() + '://' + url.host()
Example #10
0
 def test_set_query(self):
     url = URL.from_string('http://www.google.com/').query('q=testing')
     self.assertEqual('testing', url.query_param('q'))
Example #11
0
 def test_set_path(self):
     url = URL.from_string('http://www.google.com/').path('search')
     self.assertEqual('/search', url.path())
Example #12
0
 def test_set_scheme(self):
     url = URL.from_string('http://www.google.com/').scheme('https')
     self.assertEqual('https', url.scheme())
Example #13
0
 def test_set_fragment(self):
     url = URL.from_string('http://www.google.com/').fragment('hello')
     self.assertEqual('hello', url.fragment())
Example #14
0
 def test_list_extraction(self):
     url = URL.from_string('http://www.google.com/?q=1&q=2&q=3')
     self.assertEqual(['1', '2', '3'], url.query_param('q'))
Example #15
0
File: tests.py Project: st4lk/purl
 def test_urls_are_hashable(self):
     u = URL.from_string('http://google.com')
     hash(u)
Example #16
0
 def test_negative_equality_comparison(self):
     self.assertNotEqual(URL.from_string('http://google.com'),
                         URL.from_string('https://google.com'))
Example #17
0
 def test_set_query_params(self):
     url = URL.from_string('http://www.google.com/search').query_params({'q': 'testing'})
     self.assertEqual('testing', url.query_param('q'))
Example #18
0
 def test_set_path_segment(self):
     url = URL.from_string('http://www.google.com/a/b/c/').path_segment(1, 'd')
     self.assertEqual('/a/d/c/', url.path())
Example #19
0
 def test_set_port(self):
     url = URL.from_string('http://www.google.com/').port(8000)
     self.assertEqual(8000, url.port())
Example #20
0
 def test_set_query(self):
     url = URL.from_string('http://www.google.com/').query('q=testing')
     self.assertEqual('testing', url.query_param('q'))
Example #21
0
 def test_set_path(self):
     url = URL.from_string('http://www.google.com/').path('search')
     self.assertEqual('/search', url.path())
Example #22
0
 def test_set_host(self):
     url = URL.from_string('http://www.google.com/').host('maps.google.com')
     self.assertEqual('maps.google.com', url.host())
Example #23
0
 def test_set_scheme(self):
     url = URL.from_string('http://www.google.com/').scheme('https')
     self.assertEqual('https', url.scheme())
Example #24
0
 def test_set_path_segment(self):
     url = URL.from_string('http://www.google.com/a/b/c/').path_segment(
         1, 'd')
     self.assertEqual('/a/d/c/', url.path())
Example #25
0
 def test_set_subdomain(self):
     url = URL.from_string('http://www.google.com/search').subdomain(
         0, 'www2')
     self.assertEqual('www2', url.subdomain(0))
Example #26
0
 def test_set_subdomain(self):
     url = URL.from_string('http://www.google.com/search').subdomain(0, 'www2')
     self.assertEqual('www2', url.subdomain(0))
Example #27
0
 def test_urls_can_be_pickled(self):
     u = URL.from_string('http://google.com')
     pickle.dumps(u)
Example #28
0
 def test_unicode_username_and_password(self):
     url = URL.from_string('postgres://jeść:niejeść@127.0.0.1:5432/db_name')
     self.assertEqual('jeść', url.username())
     self.assertEqual('niejeść', url.password())
Example #29
0
 def setUp(self):
     self.url_str = 'http://www.google.com/search/?q=testing#fragment'
     self.url = URL.from_string(self.url_str)
Example #30
0
 def test_port_for_https_url(self):
     url = URL.from_string('https://github.com')
     self.assertEqual(None, url.port())
Example #31
0
 def setUp(self):
     self.url_str = 'https://www.sandbox.paypal.com/webscr?cmd=_express-checkout&token=EC-6469953681606921P&AMT=200&CURRENCYCODE=GBP&RETURNURL=http%3A%2F%2Fexample.com%2Fcheckout%2Fpaypal%2Fresponse%2Fsuccess%2F&CANCELURL=http%3A%2F%2Fexample.com%2Fcheckout%2Fpaypal%2Fresponse%2Fcancel%2F'
     self.url = URL.from_string(self.url_str)
Example #32
0
 def test_setting_list_as_query_params(self):
     first = URL.from_string('?q=testing')
     second = URL().query_params(first.query_params())
     self.assertEqual(first.query(), second.query())
Example #33
0
 def test_unicode_username_only(self):
     url = URL.from_string('postgres://jeść@127.0.0.1:5432/db_name')
     self.assertEqual('jeść', url.username())
     self.assertTrue(url.password() is None)
Example #34
0
 def setUp(self):
     self.url_str = 'http://www.google.com/search/?q=testing#fragment'
     self.url = URL.from_string(self.url_str)
Example #35
0
 def setUp(self):
     self.url = URL.from_string(
         'http://www.google.com/blog/article/1?q=testing')
Example #36
0
 def test_no_equals_sign_means_empty_string(self):
     url = URL.from_string('http://www.google.com/blog/article/1?q') 
     self.assertEqual('', url.query_param('q'))
Example #37
0
 def test_set_fragment(self):
     url = URL.from_string('http://www.google.com/').fragment('hello')
     self.assertEqual('hello', url.fragment())
Example #38
0
 def test_list_extraction(self):
     url = URL.from_string('http://www.google.com/?q=1&q=2&q=3') 
     self.assertEqual(['1', '2', '3'], url.query_param('q'))
Example #39
0
 def test_set_host(self):
     url = URL.from_string('http://www.google.com/').host('maps.google.com')
     self.assertEqual('maps.google.com', url.host())
Example #40
0
 def test_username_extraction(self):
     url = URL.from_string('ftp://*****:*****@ftp.host') 
     self.assertEqual('user', url.username())
     self.assertEqual('pw', url.password())
Example #41
0
 def test_set_path_with_special_chars(self):
     url = URL.from_string('http://www.google.com/').path(
         'search something')
     self.assertEqual('/search%20something', url.path())
Example #42
0
 def test_username_in_unicode_repr(self):
     u = 'ftp://*****:*****@ftp.host'
     url = URL.from_string(u) 
     self.assertEqual(u, str(url))
Example #43
0
 def test_set_port(self):
     url = URL.from_string('http://www.google.com/').port(8000)
     self.assertEqual(8000, url.port())
Example #44
0
 def test_auth_in_netloc(self):
     url = URL.from_string('ftp://*****:*****@ftp.host') 
     self.assertEqual('user:[email protected]', url.netloc())
Example #45
0
 def test_set_query_params(self):
     url = URL.from_string('http://www.google.com/search').query_params(
         {'q': 'testing'})
     self.assertEqual('testing', url.query_param('q'))
Example #46
0
 def test_port_for_https_url(self):
     url = URL.from_string('https://github.com') 
     self.assertEqual(None, url.port())
Example #47
0
 def test_url_can_be_used_as_key_in_dict(self):
     u = URL.from_string('http://google.com')
     {u: 0}
Example #48
0
 def setUp(self):
     self.url = URL.from_string('http://www.google.com/blog/article/1?q=testing') 
Example #49
0
 def test_urls_are_hashable(self):
     u = URL.from_string('http://google.com')
     hash(u)
Example #50
0
File: tests.py Project: st4lk/purl
 def test_urls_can_be_pickled_and_restored(self):
     u = URL.from_string('http://google.com')
     pickled = pickle.dumps(u)
     v = pickle.loads(pickled)
     self.assertEqual(u, v)
Example #51
0
 def test_urls_can_be_pickled_and_restored(self):
     u = URL.from_string('http://google.com')
     pickled = pickle.dumps(u)
     v = pickle.loads(pickled)
     self.assertEqual(u, v)
Example #52
0
File: tests.py Project: st4lk/purl
 def test_urls_can_be_pickled(self):
     u = URL.from_string('http://google.com')
     pickle.dumps(u)
Example #53
0
 def setUp(self):
     self.url_str = 'https://www.sandbox.paypal.com/webscr?cmd=_express-checkout&token=EC-6469953681606921P&AMT=200&CURRENCYCODE=GBP&RETURNURL=http%3A%2F%2Fexample.com%2Fcheckout%2Fpaypal%2Fresponse%2Fsuccess%2F&CANCELURL=http%3A%2F%2Fexample.com%2Fcheckout%2Fpaypal%2Fresponse%2Fcancel%2F'
     self.url = URL.from_string(self.url_str)
Example #54
0
File: tests.py Project: st4lk/purl
 def test_negative_equality_comparison(self):
     self.assertNotEqual(URL.from_string('http://google.com'),
                         URL.from_string('https://google.com'))
Example #55
0
 def test_no_equals_sign_means_empty_string(self):
     url = URL.from_string('http://www.google.com/blog/article/1?q')
     self.assertEqual('', url.query_param('q'))
 def perform_action(self):
     self.add_product_to_basket()
     response = self.client.get(reverse('paypal-redirect'))
     self.url = URL.from_string(response['Location'])
Example #57
0
 def test_username_extraction(self):
     url = URL.from_string('ftp://*****:*****@ftp.host')
     self.assertEqual('user', url.username())
     self.assertEqual('pw', url.password())
Example #58
0
File: tests.py Project: st4lk/purl
 def test_port_in_netloc(self):
     url = URL.from_string('http://localhost:5000')
     self.assertEqual('localhost', url.host())
     self.assertEqual(5000, url.port())
Example #59
0
 def assertIsRedirect(self, response, expected_url=None):
     self.assertTrue(response.status_code in (
         http_client.FOUND, http_client.MOVED_PERMANENTLY))
     if expected_url:
         location = URL.from_string(response['Location'])
         self.assertEqual(expected_url, location.path())
 def test_empty_basket_shows_error(self):
     url = reverse('paypal-redirect')
     response = self.client.get(url)
     self.assertEqual(reverse('basket:summary'), URL.from_string(response['Location']).path())