-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added test cases for updated subscriber dto field related to credentials
- Loading branch information
1 parent
659e533
commit 1cc85e3
Showing
1 changed file
with
77 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,7 +11,7 @@ | |
SubscriberPreferencePreferenceDto, | ||
SubscriberPreferenceTemplateDto, | ||
) | ||
from novu.enums import Channel | ||
from novu.enums import Channel, ChatProviderIdEnum | ||
from tests.factories import MockResponse | ||
|
||
|
||
|
@@ -47,6 +47,7 @@ def setUpClass(cls) -> None: | |
_id="63dafedbc037e013fd82d37a", | ||
_environment_id="63dafed97779f59258e38445", | ||
_organization_id="63dafed97779f59258e3843f", | ||
channels=[], | ||
deleted=False, | ||
created_at="2023-02-02T00:07:55.459Z", | ||
updated_at="2023-02-06T23:03:22.645Z", | ||
|
@@ -153,6 +154,81 @@ def test_get_subscriber(self, mock_request: mock.MagicMock) -> None: | |
timeout=5, | ||
) | ||
|
||
@mock.patch("requests.request") | ||
def test_get_subscriber_with_credentials_info(self, mock_request: mock.MagicMock) -> None: | ||
mock_request.return_value = MockResponse( | ||
200, | ||
{ | ||
"data": { | ||
"_id": "63dafedbc037e013fd82d37a", | ||
"_organizationId": "63dafed97779f59258e3843f", | ||
"_environmentId": "63dafed97779f59258e38445", | ||
"subscriberId": "63dafed4117f8c850991ec4a", | ||
"channels": [ | ||
{ | ||
'provider_id': 'slack', | ||
'_integration_id': '64f6d74be166fcd7f2751111', | ||
'credentials': { | ||
'webhook_url': 'TEST', | ||
'channel': 'slack', | ||
'device_tokens': ["TEST"] | ||
}, | ||
'integration_identifier': None | ||
} | ||
], | ||
"deleted": False, | ||
"createdAt": "2023-02-02T00:07:55.459Z", | ||
"updatedAt": "2023-02-06T23:03:22.645Z", | ||
"__v": 0, | ||
"isOnline": False, | ||
"email": "[email protected]", | ||
"lastOnlineAt": "2023-02-06T23:03:22.645Z", | ||
} | ||
}, | ||
) | ||
|
||
res = self.api.get("subscriber-id") | ||
self.assertIsInstance(res, SubscriberDto) | ||
self.assertEqual( | ||
res, | ||
SubscriberDto( | ||
subscriber_id="63dafed4117f8c850991ec4a", | ||
email="[email protected]", | ||
first_name=None, | ||
last_name=None, | ||
phone=None, | ||
avatar=None, | ||
locale=None, | ||
_id="63dafedbc037e013fd82d37a", | ||
_environment_id="63dafed97779f59258e38445", | ||
_organization_id="63dafed97779f59258e3843f", | ||
channels=[ChannelSettingsDto( | ||
provider_id=ChatProviderIdEnum.SLACK, | ||
_integration_id='64f6d74be166fcd7f2751111', | ||
credentials=ChannelSettingsCredentialsDto( | ||
webhook_url='TEST', | ||
channel='slack', | ||
device_tokens=["TEST"] | ||
), | ||
integration_identifier=None | ||
)], | ||
deleted=False, | ||
created_at="2023-02-02T00:07:55.459Z", | ||
updated_at="2023-02-06T23:03:22.645Z", | ||
is_online=False, | ||
last_online_at="2023-02-06T23:03:22.645Z", | ||
) | ||
) | ||
|
||
mock_request.assert_called_once_with( | ||
method="GET", | ||
url="sample.novu.com/v1/subscribers/subscriber-id", | ||
headers={"Authorization": "ApiKey api-key"}, | ||
json=None, | ||
params=None, | ||
timeout=5, | ||
) | ||
|
||
@mock.patch("requests.request") | ||
def test_update_subscriber(self, mock_request: mock.MagicMock) -> None: | ||
mock_request.return_value = MockResponse(200, self.response_get) | ||
|