コード例 #1
0
ファイル: tests.py プロジェクト: brianjpetersen/exfoliate
 def test_multiple_clients(self):
     client_1 = exfoliate.Client()
     client_2 = exfoliate.Client()
     future_1 = client_1.get('https://httpbin.org/anything')
     future_2 = client_2.get('https://httpbin.org/anything')
     assert future_1.response().json() == future_2.response().json()
     assert client_1.connector != client_2.connector
コード例 #2
0
ファイル: tests.py プロジェクト: brianjpetersen/exfoliate
 def test_nonblocking(self):
     client = exfoliate.Client()
     blocking_future = client.get('https://httpbin.org/delay/1')
     nonblocking_future = client.get('https://httpbin.org/delay/0')
     target_futures = (nonblocking_future, blocking_future, )
     for future, target_future in zip(client.futures, target_futures):
         assert future == target_future
コード例 #3
0
ファイル: tests.py プロジェクト: brianjpetersen/exfoliate
 def test_repeat_request(self):
     client = exfoliate.Client()
     future_initial = client.get('https://httpbin.org/anything')
     response_initial = future_initial.response().json()
     future_repeated = future_initial.repeat()
     response_repeated = future_repeated.response().json()
     assert response_repeated == response_initial
コード例 #4
0
ファイル: tests.py プロジェクト: brianjpetersen/exfoliate
 def test_default_cookie_isolation(self):
     client = exfoliate.Client()
     future_1 = client.get('https://httpbin.org/cookies/set?a=1&c=3')
     future_2 = client.get('https://httpbin.org/cookies/set?b=2&c=3')
     response_1 = future_1.response().json()
     response_2 = future_2.response().json()
     assert response_1 == {'cookies': {'a': '1', 'c': '3'}}
     assert response_2 == {'cookies': {'b': '2', 'c': '3'}}
コード例 #5
0
ファイル: tests.py プロジェクト: brianjpetersen/exfoliate
 def test_methods(self):
     client = exfoliate.Client()
     for method_name in ('GET', 'PUT', 'POST', 'DELETE', ):
         method = getattr(client, method_name.lower())
         future = method('https://httpbin.org/anything')
         response = future.response()
         assert response.status_code == 200
         assert response.json()['method'] == method_name
コード例 #6
0
ファイル: tests.py プロジェクト: brianjpetersen/exfoliate
 def test_shared_cookies(self):
     cookie_jar = exfoliate.CookieJar()
     client = exfoliate.Client(cookie_jar=cookie_jar)
     future_1 = client.get('https://httpbin.org/cookies/set?a=1&c=3')
     response_1 = future_1.response().json()
     future_2 = client.get('https://httpbin.org/cookies/set?b=2&c=3')
     response_2 = future_2.response().json()
     assert response_1 == {'cookies': {'a': '1', 'c': '3'}}
     assert response_2 == {'cookies': {'a': '1', 'b': '2', 'c': '3'}}
コード例 #7
0
ファイル: tests.py プロジェクト: brianjpetersen/exfoliate
 def test_headers(self):
     client = exfoliate.Client()
     headers = {'X-Test-Exfoliate': 'awesome'}
     future = client.get('https://httpbin.org/headers', headers=headers)
     response = future.response().json()
     assert response['headers']['X-Test-Exfoliate'] == 'awesome'
コード例 #8
0
ファイル: tests.py プロジェクト: brianjpetersen/exfoliate
 def test_text(self):
     client = exfoliate.Client()
     future = client.get('https://httpbin.org/encoding/utf8')
     response = future.response()
     assert len(response.text()) == 7808
     assert len(response.content) == 14239