-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Tests added for feedback messages and common messages (#93)
* tests added for feedback messages * tests added for common messages * newline added
- Loading branch information
1 parent
ba8247c
commit 06fd0e0
Showing
2 changed files
with
54 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
from fyle_slack_app.slack.ui import common_messages | ||
|
||
class TestCommonMessages: | ||
|
||
def test_get_custom_text_section_block(self): | ||
MESSAGE = "Hi there, I am using fyle" | ||
section_block = common_messages.get_custom_text_section_block(message=MESSAGE) | ||
assert section_block[0]['text']['text'] == MESSAGE | ||
|
||
def test_get_updated_approval_notification_message(self): | ||
FAKE_NOTIFICATION_MESSAGES = [{ | ||
'type': 'section', | ||
'text': { | ||
'type': 'mrkdwn', | ||
'text': 'Hey there' | ||
} | ||
}, | ||
{ | ||
'type': 'actions', | ||
'text': { | ||
'type': 'mrkdwn', | ||
'text': 'Hey there' | ||
} | ||
} | ||
] | ||
FAKE_CUSTOM_MESSAGE = 'Hello World' | ||
report_notification_message1 = common_messages.get_updated_approval_notification_message(FAKE_NOTIFICATION_MESSAGES, FAKE_CUSTOM_MESSAGE, True) | ||
report_notification_message2 = common_messages.get_updated_approval_notification_message(FAKE_NOTIFICATION_MESSAGES, FAKE_CUSTOM_MESSAGE, False) | ||
assert report_notification_message1[-1]['text']['text'] == FAKE_CUSTOM_MESSAGE | ||
assert report_notification_message2[-1]['text']['text'] == FAKE_CUSTOM_MESSAGE | ||
|
||
for notification_message in report_notification_message2: | ||
if 'type' in notification_message: | ||
assert notification_message['type'] != 'actions' |
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 |
---|---|---|
@@ -0,0 +1,20 @@ | ||
from fyle_slack_app.slack.ui import feedbacks | ||
|
||
class TestFeedbackMessages: | ||
|
||
def test_get_user_feedback_message(self): | ||
feedback_trigger = 'fake_feedback_trigger' | ||
feedback_message_blocks = feedbacks.messages.get_user_feedback_message(feedback_trigger) | ||
assert feedback_message_blocks[1]['elements'][0]['value'] == feedback_trigger | ||
|
||
def test_get_post_feedback_submission_message(self): | ||
feedback_message_blocks = feedbacks.messages.get_post_feedback_submission_message() | ||
assert feedback_message_blocks[0]['text']['text'] == 'Thanks for submitting the feedback :rainbow:' | ||
|
||
def test_get_feedback_dialog(self): | ||
private_metadata = 'fake_private_metadata' | ||
feedback_dialog = feedbacks.messages.get_feedback_dialog(private_metadata) | ||
feedback_rating_options = feedback_dialog['blocks'][2]['element']['options'] | ||
for rating in range(10): | ||
assert feedback_rating_options[rating]['text']['text'] == '{} :star:'.format(rating+1) | ||
assert feedback_rating_options[rating]['value'] == str(rating+1) |