Exemplo n.º 1
0
 def test_put_chatstate_ok(self):
     new_state = factories.StateFactory(bot=self.bot)
     data = self._test_put_detail_ok(self._chatstate_detail_url(), 
                                     {'chat': self.chat, 'state': {'name': new_state.name}}, 
                                     MessengerChatStateDetail, self.bot.pk, self.chatstate.pk)
     updated = MessengerChatState.objects.get(pk=self.chatstate.pk)
     self.assertEqual(updated.state.name, new_state.name)
     self.assertMessengerChatState(data['id'], data['created_at'], data['updated_at'], data['state']['name'], data['chat'], updated)
Exemplo n.º 2
0
 def setUp(self):
     super(TestKikChatStateAPI, self).setUp()
     self.state = factories.StateFactory(bot=self.bot)
     self.user = factories.KikUserAPIFactory(username=self.kik_message.from_user)
     self.chat = factories.KikChatAPIFactory(id=self.kik_message.chat_id)
     self.chatstate = factories.KikChatStateFactory(state=self.state,
                                                    chat=self.chat,
                                                    user=self.user)
Exemplo n.º 3
0
 def setUp(self):
     super(TestTelegramChatStateAPI, self).setUp()
     self.state = factories.StateFactory(bot=self.bot)
     self.user = factories.TelegramUserAPIFactory(id=self.telegram_update.message.from_user.id,
                                                  username=self.telegram_update.message.from_user.username,
                                                  first_name=self.telegram_update.message.from_user.first_name,
                                                  last_name=self.telegram_update.message.from_user.last_name)
     self.chat = factories.TelegramChatAPIFactory(id=self.telegram_update.message.chat.id,
                                                  type=self.telegram_update.message.chat.type, 
                                                  title=self.telegram_update.message.chat.title,
                                                  username=self.telegram_update.message.chat.username,
                                                  first_name=self.telegram_update.message.chat.first_name,
                                                  last_name=self.telegram_update.message.chat.last_name)
     self.chatstate = factories.TelegramChatStateFactory(state=self.state,
                                                         chat=self.chat,
                                                         user=self.user)
Exemplo n.º 4
0
 def setUp(self):
     super(TestStateAPI, self).setUp()
     self.state = factories.StateFactory(bot=self.bot)
Exemplo n.º 5
0
 def test_put_chatstate_not_found(self):
     new_state = factories.StateFactory(bot=self.bot)
     self._test_put_detail_not_found(self._chatstate_detail_url(chatstate_pk=self.unlikely_id), 
                                     {'chat': self.chat, 'state': {'name': new_state.name}}, MessengerChatStateDetail, 
                                     self.bot.pk, self.unlikely_id)
Exemplo n.º 6
0
 def test_put_chatstate_not_auth(self):
     new_state = factories.StateFactory(bot=self.bot)
     self._test_put_detail_not_auth(self._chatstate_detail_url(), {'chat': self.chat, 'state': {'name': new_state.name}}, 
                                    MessengerChatStateDetail, self.bot.pk, self.chatstate.pk)
Exemplo n.º 7
0
 def test_put_chatstate_from_other_bot(self):
     new_state = factories.StateFactory(bot=self.bot)
     self._test_put_detail_from_other_bot(self._chatstate_detail_url, 
                                          {'chat': self.chat, 'state': {'name': new_state.name}}, 
                                          MessengerChatStateDetail, self.chatstate.pk)
Exemplo n.º 8
0
 def test_put_chatstate_only_state_ok(self):
     new_state = factories.StateFactory(bot=self.bot)
     self._test_put_detail_ok(self._chatstate_detail_url(), 
                              {'state': {'name': new_state.name}}, 
                              MessengerChatStateDetail, self.bot.pk, self.chatstate.pk)
     self.assertEqual(MessengerChatState.objects.get(pk=self.chatstate.pk).state.name, new_state.name)
Exemplo n.º 9
0
 def setUp(self):
     super(TestMessengerChatStateAPI, self).setUp()
     self.state = factories.StateFactory(bot=self.bot)
     self.chat = self.messenger_text_message.sender
     self.chatstate = factories.MessengerChatStateFactory(state=self.state,
                                                          chat=self.chat)
Exemplo n.º 10
0
 def test_put_chatstate_not_auth(self):
     new_state = factories.StateFactory(bot=self.bot)
     self._test_put_detail_not_auth(self._chatstate_detail_url(), {'chat': self.chat.id, 'user': self.user.username, 'state': {'name': new_state.name}}, 
                                    KikChatStateDetail, self.bot.pk, self.chatstate.pk)
Exemplo n.º 11
0
 def test_put_chatstate_from_other_bot(self):
     new_state = factories.StateFactory(bot=self.bot)
     self._test_put_detail_from_other_bot(self._chatstate_detail_url, 
                                          {'chat': self.chat.id, 'user': self.user.username, 'state': {'name': new_state.name}}, 
                                          KikChatStateDetail, self.chatstate.pk)