Skip to content

Commit 249f421

Browse files
committed
Add (minimal implementation of) UrlboxClient both code and tests.
This is the core client object used to interact with the Urlbox API. I just wanted to get a class and basic test coverage working so we can test all the mechanics work in Github CI. Further work will add the get() instance method to this class that will make the basic get request to the API.
1 parent 395ff64 commit 249f421

File tree

6 files changed

+65
-7
lines changed

6 files changed

+65
-7
lines changed

.github/workflows/tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
- name: Install dependencies
1919
run: |
2020
python -m pip install --upgrade pip
21-
python -m pip install pytest pytest-mock pytest-socket
21+
python -m pip install Faker pytest pytest-mock pytest-socket
2222
- name: Test with pytest
2323
run: |
2424
pytest

tests/test_temp.py

Lines changed: 0 additions & 4 deletions
This file was deleted.

tests/test_urlbox_client.py

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
from faker import Faker
2+
from urlbox import UrlboxClient
3+
import pytest
4+
5+
fake = Faker()
6+
7+
# Fixtures
8+
@pytest.fixture
9+
def api_key():
10+
return fake.pystr()
11+
12+
13+
@pytest.fixture
14+
def api_secret():
15+
return fake.pystr()
16+
17+
18+
# Tests
19+
# test_init()
20+
21+
22+
def test_only_api_key_provided():
23+
urlbox_client = UrlboxClient(api_key=api_key)
24+
25+
assert urlbox_client.api_key == api_key
26+
27+
28+
def test_both_api_key_and_api_secret_provided():
29+
urlbox_client = UrlboxClient(api_key=api_key, api_secret=api_secret)
30+
31+
assert (
32+
urlbox_client.api_key == api_key
33+
and urlbox_client.api_secret == api_secret
34+
)
35+
36+
37+
def test_api_key_not_provided():
38+
with pytest.raises(TypeError) as type_error:
39+
UrlboxClient()
40+
41+
assert (
42+
str(type_error.value)
43+
== "__init__() missing 1 required keyword-only argument: 'api_key'"
44+
)

urlbox/.gitkeep

Lines changed: 0 additions & 2 deletions
This file was deleted.

urlbox/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from urlbox.urlbox_client import UrlboxClient

urlbox/urlbox_client.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
class UrlboxClient:
2+
3+
"""
4+
The core client object used to interact with the Urlbox API
5+
6+
:param api_key: Your API key found in your Urlbox Dashboard
7+
`https://urlbox.io/dashboard/api`
8+
9+
:param api_secret: (Optional) Your API secret found in your Urlbox
10+
Dashboard`https://urlbox.io/dashboard/api`
11+
Required for authenticated requests.
12+
"""
13+
14+
def __init__(self, *, api_key, api_secret=None):
15+
self.api_key = api_key
16+
self.api_secret = api_secret
17+
18+
def get():
19+
pass

0 commit comments

Comments
 (0)