Пример #1
0
def test_https_request_basic(get_patch):
    res_patch = mock.Mock(spec=requests.Response)
    res_patch.status_code = 200
    get_patch.return_value = res_patch
    api = API()
    api._set_auth("account_id", "username", "password")
    res = api.https_request("a real url", "get", {"test": 1})
Пример #2
0
def test_session_with_headers():
    api = API()
    api._set_auth("account_id", "username", "password")
    session = api._session_with_headers()
    assert session.auth == ("username", "password")
    assert session.headers.get("Content-Type") == "application/json"
    assert session.headers.get("Accept") == "application/json"
Пример #3
0
def test_https_request_too_many(get_patch):
    res_patch = mock.Mock(spec=requests.Response)
    res_patch.status_code = 429
    res_patch.content = "{'message': 'testing'}"
    get_patch.return_value = res_patch
    api = API()
    api._set_auth("account_id", "username", "password")
    res = api.https_request("a real url", "get", {"test": 1})
Пример #4
0
def test_init():
    api = API()
    api._set_auth("account_id", "username", "password")
    assert api.account_id == "account_id"
    assert api.username == "username"
    assert api.password == "password"
Пример #5
0
def test_init_with_no_password():
    api = API()
    api._set_auth("account_id", "username", None)
Пример #6
0
def test_init_with_no_username():
    api = API()
    api._set_auth("account_id", None, "password")
Пример #7
0
def test_base_url_no_partner():
    api = API()
    api._set_auth("account_id", "username", "password")
    api.account_id = "test"
    expected = "%s/test" % BASE_URL
    assert api.base_url() == expected