Skip to content

Commit

Permalink
chore: unify and clean up unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
matsk-sinch committed Mar 7, 2025
1 parent 23cfc25 commit b02b46a
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 61 deletions.
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@ You can install this package by typing:

## Products

Sinch client provides access to the following Sinch products:
- Numbers
- SMS
- Verification
The Sinch client provides access to the following Sinch products:
- Numbers API
- SMS API
- Verification API
- Voice API
- Conversation API (beta release)

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

sinch_client = SinchClient(
key_id="key_id",
key_secret="key_secret",
project_id="project_id",
key_id="key_id",
key_secret="key_secret"
)
```

Expand Down
78 changes: 23 additions & 55 deletions tests/unit/test_client.py
Original file line number Diff line number Diff line change
@@ -1,62 +1,30 @@
import pytest
from sinch import SinchClient, SinchClientAsync
from sinch.core.clients.sinch_client_configuration import Configuration


def test_sinch_client_initialization():
sinch_client_sync = SinchClient(
key_id="test",
key_secret="test_secret",
project_id="test_project_id"
)
assert sinch_client_sync


def test_sinch_client_async_initialization():
sinch_client_async = SinchClientAsync(
@pytest.mark.parametrize("client", [SinchClient, SinchClientAsync])
def test_sinch_client_initialization(client):
""" Test that SinchClient and SinchClientAsync can be initialized with or without parameters """
sinch_client = client(
key_id="test",
key_secret="test_secret",
project_id="test_project_id"
)
assert sinch_client_async


def test_sinch_client_empty_expects_initialization():
""" Test that SinchClient can be initialized with no parameters """
sinch_client_sync = SinchClient()
assert sinch_client_sync


def test_sinch_client_async_empty_expects_initialization():
""" Test that SinchClientAsync can be initialized with no parameters """
sinch_client_async = SinchClientAsync()
assert sinch_client_async


def test_sinch_client_has_all_business_domains(sinch_client_sync):
""" Test that SinchClient has all domains """
assert hasattr(sinch_client_sync, "authentication")
assert hasattr(sinch_client_sync, "sms")
assert hasattr(sinch_client_sync, "conversation")
assert hasattr(sinch_client_sync, "numbers")
assert hasattr(sinch_client_sync, "verification")
assert hasattr(sinch_client_sync, "voice")


def test_sinch_client_async_has_all_business_domains(sinch_client_async):
""" Test that SinchClientAsync has all domains """
assert hasattr(sinch_client_async, "authentication")
assert hasattr(sinch_client_async, "sms")
assert hasattr(sinch_client_async, "conversation")
assert hasattr(sinch_client_async, "numbers")
assert hasattr(sinch_client_async, "verification")
assert hasattr(sinch_client_async, "voice")


def test_sinch_client_has_configuration_object(sinch_client_sync):
assert hasattr(sinch_client_sync, "configuration")
assert isinstance(sinch_client_sync.configuration, Configuration)


def test_sinch_client_async_has_configuration_object(sinch_client_async):
assert hasattr(sinch_client_async, "configuration")
assert isinstance(sinch_client_async.configuration, Configuration)
assert sinch_client

sinch_client_empty = client()
assert sinch_client_empty


@pytest.mark.parametrize("client", ["sinch_client_sync", "sinch_client_async"])
def test_sinch_client_expects_all_attributes(request, client):
""" Test that SinchClient and SinchClientAsync have all attributes"""
client_instance = request.getfixturevalue(client)
assert hasattr(client_instance, "authentication")
assert hasattr(client_instance, "sms")
assert hasattr(client_instance, "conversation")
assert hasattr(client_instance, "numbers")
assert hasattr(client_instance, "verification")
assert hasattr(client_instance, "voice")
assert hasattr(client_instance, "configuration")
assert isinstance(client_instance.configuration, Configuration)

0 comments on commit b02b46a

Please sign in to comment.