Esempio n. 1
0
 def test_returns_expected_end_of_story(self):
     clue = Clue(text='blah', answer_uids=[])
     group_mock = Mock(clue=clue)
     group_mock.story.end_message = "END"
     user = Mock()
     result = perform_action(ANSWER, Message(text='asdf'), user, group_mock)
     self.assertEqual([group_mock.story.end_message], [m.text for m in result.messages])
Esempio n. 2
0
 def test_returns_expected_joined_group(self, group_mock):
     clue = Clue(text='clue text')
     group = Mock(uid='code', clue_uid='MYSTORY:MYCLUE', clue=clue)
     group_mock.get_by_id.return_value = group
     user = User()
     result = perform_action(JOIN_GROUP, Message(text='join code'), user, None)
     self.assertEqual([JOINED_GROUP.text, 'clue text'], [m.text for m in result.messages])
Esempio n. 3
0
 def test_returns_expected_restarted(self):
     start_message = 'Start the story'
     clue = Clue(text=start_message)
     user = Mock()
     group_mock = Mock(clue_uid='something', clue=clue)
     result = perform_action(RESTART, Message(text='restart'), user, group_mock)
     self.assertEqual([RESTARTED.text, start_message], [m.text for m in result.messages])
Esempio n. 4
0
 def test_returns_expected_starting_new_story(self, story_code_mock, clue_mock, group_mock):
     story_code_mock.build_key.return_value.get.return_value = StoryCode(story_uid="STORY")
     clue_mock.get_by_id.return_value = Clue(text='test')
     clue = Clue(text='test')
     group_mock.return_value.current_clue = clue
     group_mock.gen_uid.return_value = 'abcd'
     user = User()
     result = perform_action(START_STORY, Message(text='start blah'), user, None)
     expected_message_text = [INTRO_INSTRUCTIONS.text, clue.text]
     self.assertEqual(expected_message_text, [m.text for m in result.messages])
Esempio n. 5
0
 def test_returns_expected_already_in_group(self):
     user = User(group_uid='code')
     result = perform_action(JOIN_GROUP, Message(text='join code'), user, Group())
     self.assertEqual([ALREADY_IN_GROUP.text], [m.text for m in result.messages])
Esempio n. 6
0
 def test_returns_expected_group_not_found(self, group_mock):
     group_mock.get_by_id.return_value = None
     user = Mock()
     result = perform_action(JOIN_GROUP, Message(text='join blah'), user, None)
     self.assertEqual([NO_GROUP_FOUND.text], [m.text for m in result.messages])
Esempio n. 7
0
 def test_gives_instructions_if_group_code_not_provided(self):
     result = perform_action(JOIN_GROUP, Message(text='join'), User(), None)
     expected_message_text = [JOIN_GROUP_INSTRUCTIONS.text]
     self.assertEqual(expected_message_text, [m.text for m in result.messages])
Esempio n. 8
0
 def test_gives_instructions_if_start_code_not_provided(self):
     result = perform_action(START_STORY, Message(text='start'), User(), None)
     expected_message_text = [START_INSTRUCTIONS.text]
     self.assertEqual(expected_message_text, [m.text for m in result.messages])
Esempio n. 9
0
 def test_returns_expected_story_not_found(self, story_code_mock):
     story_code_mock.build_key.return_value.get.return_value = None
     user = Mock()
     result = perform_action(START_STORY, Message(text='start blah'), user, None)
     self.assertEqual([STORY_NOT_FOUND], result.messages)
Esempio n. 10
0
 def test_returns_expected_how_to_start(self):
     user = User()
     result = perform_action(ANSWER, Message(text='blah'), user, None)
     self.assertEqual([HOW_TO_START.text], [m.text for m in result.messages])