Skip to content

Commit b02b46a

Browse files
committed
chore: unify and clean up unit tests
1 parent 23cfc25 commit b02b46a

File tree

2 files changed

+29
-61
lines changed

2 files changed

+29
-61
lines changed

README.md

+6-6
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,10 @@ You can install this package by typing:
3535

3636
## Products
3737

38-
Sinch client provides access to the following Sinch products:
39-
- Numbers
40-
- SMS
41-
- Verification
38+
The Sinch client provides access to the following Sinch products:
39+
- Numbers API
40+
- SMS API
41+
- Verification API
4242
- Voice API
4343
- Conversation API (beta release)
4444

@@ -86,9 +86,9 @@ For all other Sinch APIs, including SMS in US and EU regions, use the following
8686
from sinch import SinchClient
8787

8888
sinch_client = SinchClient(
89-
key_id="key_id",
90-
key_secret="key_secret",
9189
project_id="project_id",
90+
key_id="key_id",
91+
key_secret="key_secret"
9292
)
9393
```
9494

tests/unit/test_client.py

+23-55
Original file line numberDiff line numberDiff line change
@@ -1,62 +1,30 @@
1+
import pytest
12
from sinch import SinchClient, SinchClientAsync
23
from sinch.core.clients.sinch_client_configuration import Configuration
34

4-
5-
def test_sinch_client_initialization():
6-
sinch_client_sync = SinchClient(
7-
key_id="test",
8-
key_secret="test_secret",
9-
project_id="test_project_id"
10-
)
11-
assert sinch_client_sync
12-
13-
14-
def test_sinch_client_async_initialization():
15-
sinch_client_async = SinchClientAsync(
5+
@pytest.mark.parametrize("client", [SinchClient, SinchClientAsync])
6+
def test_sinch_client_initialization(client):
7+
""" Test that SinchClient and SinchClientAsync can be initialized with or without parameters """
8+
sinch_client = client(
169
key_id="test",
1710
key_secret="test_secret",
1811
project_id="test_project_id"
1912
)
20-
assert sinch_client_async
21-
22-
23-
def test_sinch_client_empty_expects_initialization():
24-
""" Test that SinchClient can be initialized with no parameters """
25-
sinch_client_sync = SinchClient()
26-
assert sinch_client_sync
27-
28-
29-
def test_sinch_client_async_empty_expects_initialization():
30-
""" Test that SinchClientAsync can be initialized with no parameters """
31-
sinch_client_async = SinchClientAsync()
32-
assert sinch_client_async
33-
34-
35-
def test_sinch_client_has_all_business_domains(sinch_client_sync):
36-
""" Test that SinchClient has all domains """
37-
assert hasattr(sinch_client_sync, "authentication")
38-
assert hasattr(sinch_client_sync, "sms")
39-
assert hasattr(sinch_client_sync, "conversation")
40-
assert hasattr(sinch_client_sync, "numbers")
41-
assert hasattr(sinch_client_sync, "verification")
42-
assert hasattr(sinch_client_sync, "voice")
43-
44-
45-
def test_sinch_client_async_has_all_business_domains(sinch_client_async):
46-
""" Test that SinchClientAsync has all domains """
47-
assert hasattr(sinch_client_async, "authentication")
48-
assert hasattr(sinch_client_async, "sms")
49-
assert hasattr(sinch_client_async, "conversation")
50-
assert hasattr(sinch_client_async, "numbers")
51-
assert hasattr(sinch_client_async, "verification")
52-
assert hasattr(sinch_client_async, "voice")
53-
54-
55-
def test_sinch_client_has_configuration_object(sinch_client_sync):
56-
assert hasattr(sinch_client_sync, "configuration")
57-
assert isinstance(sinch_client_sync.configuration, Configuration)
58-
59-
60-
def test_sinch_client_async_has_configuration_object(sinch_client_async):
61-
assert hasattr(sinch_client_async, "configuration")
62-
assert isinstance(sinch_client_async.configuration, Configuration)
13+
assert sinch_client
14+
15+
sinch_client_empty = client()
16+
assert sinch_client_empty
17+
18+
19+
@pytest.mark.parametrize("client", ["sinch_client_sync", "sinch_client_async"])
20+
def test_sinch_client_expects_all_attributes(request, client):
21+
""" Test that SinchClient and SinchClientAsync have all attributes"""
22+
client_instance = request.getfixturevalue(client)
23+
assert hasattr(client_instance, "authentication")
24+
assert hasattr(client_instance, "sms")
25+
assert hasattr(client_instance, "conversation")
26+
assert hasattr(client_instance, "numbers")
27+
assert hasattr(client_instance, "verification")
28+
assert hasattr(client_instance, "voice")
29+
assert hasattr(client_instance, "configuration")
30+
assert isinstance(client_instance.configuration, Configuration)

0 commit comments

Comments
 (0)