def test_base_init_params_become_properties(): b = BaseShortener(a=1, b=2) assert b.a == 1 assert b.b == 2 # check default params assert b.timeout == 2 assert b.verify is True
def test_base_init_params_become_properties(): # pylint: disable=E1101 shortener = BaseShortener(a=1, b=2) assert shortener.a == 1 assert shortener.b == 2 # check default params assert shortener.timeout == 2 assert shortener.verify is True
def test_base_short_method_raises_notimplemented(): b = BaseShortener() with pytest.raises(NotImplementedError): b.short('http://someurl')
def test_base_post_request_bad_url(): b = BaseShortener() url = '.....' with pytest.raises(BadURLException): b._post(url)
def test_base_post_request(): b = BaseShortener() url = 'http://httpbin.org/status/200' assert b._post(url).status_code == 200
def test_base_expand_method_bad_response(): b = BaseShortener() with pytest.raises(ExpandingErrorException): b.expand('http://httpbin.org/status/400')
def test_base_expand_method(): b = BaseShortener() url = 'http://httpbin.org/get' assert b.expand(url) == url
def test_base_proxy(proxy_url): # pylint: disable=W0621 shortener = BaseShortener(proxies={"http": proxy_url}) url = "http://httpbin.org/status/200" assert shortener._post(url).status_code == 200
def test_base_post_request_bad_url(): shortener = BaseShortener() url = "....." with pytest.raises(BadURLException): shortener._post(url)
def test_base_post_request(): shortener = BaseShortener() url = "http://httpbin.org/status/200" assert shortener._post(url).status_code == 200
def test_base_expand_method(): shortener = BaseShortener() url = "http://httpbin.org/get" assert shortener.expand(url) == url