示例#1
0
 def test_authorization_manual_key(self):
     key = os.environ['AIRTABLE_API_KEY']
     session = requests.Session()
     session.auth = AirtableAuth(api_key=key)
     resp = session.get('http://www.google.com')
     assert 'Authorization' in resp.request.headers
     assert 'Bearer' in resp.request.headers['Authorization']
示例#2
0
 def test_authorization_scheme(self):
     session = requests.Session()
     session.auth = AirtableAuth()
     with Mocker() as m:
         m.get('http://www.google.com', status_code=200)
         resp = session.get('http://www.google.com')
     assert 'Authorization' in resp.request.headers
     assert 'Bearer' in resp.request.headers['Authorization']
示例#3
0
 def test_authorization_key(self, table):
     FAKE_URL = "http://www.fake.com"
     session = requests.Session()
     session.auth = AirtableAuth(api_key="xxx")
     with Mocker() as m:
         m.get(FAKE_URL)
         resp = session.get(FAKE_URL)
     assert "Authorization" in resp.request.headers
     assert "Bearer xxx" in resp.request.headers["Authorization"]
示例#4
0
 def test_authorization_manual_call(self):
     request = requests.Request()
     auth = AirtableAuth(api_key="x")
     request = auth.__call__(request)
     assert "Authorization" in request.headers
     assert "Bearer" in request.headers["Authorization"]
示例#5
0
 def test_authorization_missing(self):
     os.environ.pop("AIRTABLE_API_KEY", None)
     with pytest.raises(KeyError):
         AirtableAuth()
示例#6
0
 def test_authorization_missing(self):
     key = os.environ.pop('AIRTABLE_API_KEY')
     session = requests.Session()
     with pytest.raises(KeyError):
         session.auth = AirtableAuth()
     os.environ['AIRTABLE_API_KEY'] = key
示例#7
0
 def test_authorization_manual_call(self):
     session = requests.Session()
     auth = AirtableAuth()
     session = auth.__call__(session)
     assert 'Authorization' in session.headers
     assert 'Bearer' in session.headers['Authorization']
示例#8
0
 def test_authorization_scheme(self):
     session = requests.Session()
     session.auth = AirtableAuth()
     resp = session.get('http://www.google.com')
     assert 'Authorization' in resp.request.headers
     assert 'Bearer' in resp.request.headers['Authorization']