-
Notifications
You must be signed in to change notification settings - Fork 58
Expand file tree
/
Copy pathtest_api_key.py
More file actions
36 lines (24 loc) · 1.16 KB
/
test_api_key.py
File metadata and controls
36 lines (24 loc) · 1.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import pytest
from easypost.models import ApiKey
@pytest.mark.vcr()
def test_all_api_keys(prod_client):
"""Tests that we can retrieve all API keys."""
api_keys = prod_client.api_keys.all()
assert all(isinstance(key, ApiKey) for key in api_keys.keys)
for child in api_keys.children:
assert all(isinstance(key, ApiKey) for key in child["keys"])
@pytest.mark.vcr()
def test_authenticated_user_api_keys(prod_client):
"""Tests that we can retrieve the authenticated user's API keys."""
user = prod_client.user.retrieve_me()
api_keys = prod_client.api_keys.retrieve_api_keys_for_user(user.id)
assert all(isinstance(key, ApiKey) for key in api_keys)
@pytest.mark.vcr()
def test_child_user_api_keys(prod_client):
"""Tests that we can retrieve a child user's API keys as the parent."""
user = prod_client.user.create(name="Test User")
child_user = prod_client.user.retrieve(user.id)
api_keys = prod_client.api_keys.retrieve_api_keys_for_user(child_user.id)
assert all(isinstance(key, ApiKey) for key in api_keys)
# Delete the user so we don't clutter up the test environment
prod_client.user.delete(child_user.id)