Skip to content

Commit

Permalink
Tests added for feedback messages and common messages (#93)
Browse files Browse the repository at this point in the history
* tests added for feedback messages
* tests added for common messages
* newline added
  • Loading branch information
vishalpandeynits authored Nov 11, 2022
1 parent ba8247c commit 06fd0e0
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 0 deletions.
34 changes: 34 additions & 0 deletions tests/messages/test_common_messages.py
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'
20 changes: 20 additions & 0 deletions tests/messages/test_feedback_messages.py
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)

0 comments on commit 06fd0e0

Please sign in to comment.