-
Notifications
You must be signed in to change notification settings - Fork 81
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
1. Added rest api to fetch the count of each status in ChannelLogs fo…
…r Campaign Analytics. 2. Added unit and integration test cases.
- Loading branch information
Nupur Khare
committed
Dec 14, 2023
1 parent
416681a
commit dcd15e1
Showing
6 changed files
with
97 additions
and
4 deletions.
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
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
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
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
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 |
---|---|---|
|
@@ -14054,6 +14054,51 @@ def test_list_whatsapp_templates_error(): | |
assert actual["message"] == "Channel not found!" | ||
|
||
|
||
def test_get_channel_logs(): | ||
from kairon.shared.chat.data_objects import ChannelLogs | ||
ChannelLogs( | ||
status='read', | ||
data={'id': 'CONVERSATION_ID', 'expiration_timestamp': '1691598412', | ||
'origin': {'type': 'business_initated'}}, | ||
initiator='business_initated', | ||
campaign_id='6779002886649302', | ||
message_id='wamid.HBgLMTIxMTU1NTc5NDcVAgARGBIyRkQxREUxRDJFQUJGMkQ3NDIZ', | ||
bot=pytest.bot, | ||
user='[email protected]' | ||
).save() | ||
ChannelLogs( | ||
status='delivered', | ||
data={'id': 'CONVERSATION_ID', 'expiration_timestamp': '1621598412', | ||
'origin': {'type': 'business_initated'}}, | ||
initiator='business_initated', | ||
campaign_id='6779002886649302', | ||
message_id='wamid.HBgLMTIxMTU1NTc5NDcVAgARGBIyRkQxREUxRDJFQUJGMkQ3NDIZ', | ||
bot=pytest.bot, | ||
user='[email protected]' | ||
).save() | ||
ChannelLogs( | ||
status='sent', | ||
data={'id': 'CONVERSATION_ID', 'expiration_timestamp': '1631598412', | ||
'origin': {'type': 'business_initated'}}, | ||
initiator='business_initated', | ||
campaign_id='6779002886649302', | ||
message_id='wamid.HBgLMTIxMTU1NTc5NDcVAgARGBIyRkQxREUxRDJFQUJGMkQ3NDIZ', | ||
bot=pytest.bot, | ||
user='[email protected]' | ||
).save() | ||
response = client.get( | ||
f"/api/bot/{pytest.bot}/channels/whatsapp/logs", | ||
headers={"Authorization": pytest.token_type + " " + pytest.access_token}, | ||
) | ||
actual = response.json() | ||
print(actual) | ||
assert actual["success"] | ||
assert actual["error_code"] == 0 | ||
assert actual["data"] == {'count': [{'status': 'delivered', 'campaign_id': '6779002886649302', 'cnt': 1}, | ||
{'status': 'read', 'campaign_id': '6779002886649302', 'cnt': 1}, | ||
{'status': 'sent', 'campaign_id': '6779002886649302', 'cnt': 1}]} | ||
|
||
|
||
@responses.activate | ||
def test_initiate_bsp_onboarding_without_channels(monkeypatch): | ||
def _mock_get_bot_settings(*args, **kwargs): | ||
|
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