예제 #1
0
파일: utils.py 프로젝트: Qabel/qabel-index
 def test_check(self):
     aa = AccountingAuthorization()
     session = MagicMock()
     token = "Token 1234"
     ok, reason = aa.check(token, session)
     assert not ok
     json = {"auth": token}
     session.post.assert_called_once_with(aa.endpoint_url(), headers=aa.headers(), json=json)
예제 #2
0
파일: utils.py 프로젝트: audax/qabel-index
 def test_check_response(self, status_code, json, ok, reason):
     aa = AccountingAuthorization()
     response = MagicMock()
     response.status_code = status_code
     response.json.return_value = json
     result, result_reason = aa.check_response(response)
     assert result is ok
     if reason:
         assert result_reason == reason
예제 #3
0
파일: utils.py 프로젝트: Qabel/qabel-index
 def test_check_response(self, status_code, json, ok, reason):
     aa = AccountingAuthorization()
     response = MagicMock()
     response.status_code = status_code
     response.json.return_value = json
     result, result_reason = aa.check_response(response)
     assert result is ok
     if reason:
         assert result_reason == reason
예제 #4
0
파일: utils.py 프로젝트: audax/qabel-index
 def test_check(self):
     aa = AccountingAuthorization()
     session = MagicMock()
     token = 'Token 1234'
     ok, reason = aa.check(token, session)
     assert not ok
     json = {
         'auth': token,
     }
     session.post.assert_called_once_with(aa.endpoint_url(), headers=aa.headers(), json=json)
예제 #5
0
파일: utils.py 프로젝트: audax/qabel-index
 def test_endpoint_url(self, settings):
     aa = AccountingAuthorization()
     settings.ACCOUNTING_URL = 'gopher://accounting.plan9/foo'
     assert aa.endpoint_url() == 'gopher://accounting.plan9/foo/api/v0/internal/user/'
예제 #6
0
파일: utils.py 프로젝트: audax/qabel-index
 def test_headers(self, settings):
     aa = AccountingAuthorization()
     settings.ACCOUNTING_APISECRET = 'foo und bar'
     headers = aa.headers()
     assert len(headers) == 1
     assert headers['APISECRET'] == 'foo und bar'
예제 #7
0
파일: utils.py 프로젝트: Qabel/qabel-index
 def test_endpoint_url(self, settings):
     aa = AccountingAuthorization()
     settings.ACCOUNTING_URL = "gopher://accounting.plan9/foo"
     assert aa.endpoint_url() == "gopher://accounting.plan9/foo/api/v0/internal/user/"
예제 #8
0
파일: utils.py 프로젝트: Qabel/qabel-index
 def test_headers(self, settings):
     aa = AccountingAuthorization()
     settings.ACCOUNTING_APISECRET = "foo und bar"
     headers = aa.headers()
     assert len(headers) == 1
     assert headers["APISECRET"] == "foo und bar"