Exemplo n.º 1
0
 def test_init__message_with_reply(self, telepot):
     telepot.glance.return_value = 'text', 'private', 31416
     self.message_json['text'] = 'foo'
     message = Message(self.message_json)
     self.assertFalse(message.is_reply)
     self.message_json['reply_to_message'] = None
     message = Message(self.message_json)
     self.assertTrue(message.is_reply)
Exemplo n.º 2
0
 def test_init__sticker(self):
     self.message_json['sticker'] = self.sticker
     message = Message(self.message_json)
     self.assertEqual(
         message.sending_kwargs,
         {'sticker': 'BQADAgAD7gAD9HsZAAFCdfFWtd5o1gI'},
     )
Exemplo n.º 3
0
 def test_init__invalid_location(self, telepot):
     self.message_json['location'] = {
         'latitude': 'foo',
     }
     telepot.glance.return_value = 'location', 'private', 31416
     with self.assertRaises(UnsupportedContentError):
         Message(self.message_json)
Exemplo n.º 4
0
 def test_init__text(self):
     self.message_json['text'] = 'foo'
     message = Message(self.message_json)
     self.assertEqual(
         message.sending_kwargs,
         {'text': 'foo'},
     )
     self.assertEqual(message.text, 'foo')
Exemplo n.º 5
0
 def test_init__document(self):
     self.message_json['document'] = {
         'file_id': 'foo',
     }
     message = Message(self.message_json)
     self.assertEqual(
         message.sending_kwargs,
         {
             'document': 'foo',
         },
     )
Exemplo n.º 6
0
 def test_init__voice(self):
     self.message_json['voice'] = {
         'file_id': 'foo',
     }
     message = Message(self.message_json)
     self.assertEqual(
         message.sending_kwargs,
         {
             'voice': 'foo',
             'duration': None,
         },
     )
Exemplo n.º 7
0
 def test_init__location(self):
     self.message_json['location'] = {
         'latitude': 'foo',
         'longitude': 'bar',
     }
     message = Message(self.message_json)
     self.assertEqual(
         message.sending_kwargs,
         {
             'latitude': 'foo',
             'longitude': 'bar',
         },
     )
Exemplo n.º 8
0
 def test_init__photo_with_caption(self):
     self.message_json['photo'] = [
         {'file_id': 'foo'},
         {'file_id': 'bar'},
         ]
     self.message_json['caption'] = 'baz'
     message = Message(self.message_json)
     self.assertEqual(
         message.sending_kwargs,
         {
             'caption': 'baz',
             'photo': 'foo',
             },
         )
Exemplo n.º 9
0
 def test_init__audio(self):
     self.message_json['audio'] = {
         'file_id': 'foo',
     }
     message = Message(self.message_json)
     self.assertEqual(
         message.sending_kwargs,
         {
             'audio': 'foo',
             'duration': None,
             'performer': None,
             'title': None,
         },
     )
Exemplo n.º 10
0
 def test_init__photo(self):
     self.message_json['photo'] = [
         {'file_id': 'foo'},
         {'file_id': 'bar'},
         ]
     message = Message(self.message_json)
     self.assertEqual(
         message.sending_kwargs,
         {
             'caption': None,
             'photo': 'foo',
             },
         )
     self.assertEqual(message.text, None)
Exemplo n.º 11
0
 def test_init__video_with_info(self):
     self.message_json['video'] = {
         'duration': 85,
         'file_id': 'foo',
     }
     self.message_json['caption'] = 'Pink Floyd'
     message = Message(self.message_json)
     self.assertEqual(
         message.sending_kwargs,
         {
             'video': 'foo',
             'duration': 85,
             'caption': 'Pink Floyd',
         },
     )
Exemplo n.º 12
0
 def test_init__audio_with_info(self):
     self.message_json['audio'] = {
         'duration': 85,
         'file_id': 'foo',
         'performer': 'Pink Floyd',
         'title': 'Another Brick In The Wall Part 3',
     }
     message = Message(self.message_json)
     self.assertEqual(
         message.sending_kwargs,
         {
             'audio': 'foo',
             'duration': 85,
             'performer': 'Pink Floyd',
             'title': 'Another Brick In The Wall Part 3',
         },
     )
Exemplo n.º 13
0
 def test_init__command_without_args(self, telepot):
     telepot.glance.return_value = 'text', 'private', 31416
     self.message_json['text'] = '/start'
     message = Message(self.message_json)
     self.assertEqual(message.command, 'start')
     self.assertEqual(message.command_args, '')
Exemplo n.º 14
0
 def test_init__text_without_command_has_empty_comand_field(self, telepot):
     telepot.glance.return_value = 'text', 'private', 31416
     self.message_json['text'] = 'foo'
     message = Message(self.message_json)
     self.assertEqual(message.command, None)
     self.assertEqual(message.command_args, None)
Exemplo n.º 15
0
 def test_init__unknown_content_type(self, telepot):
     telepot.glance.return_value = 'foo_content_type', 'private', 31416
     with self.assertRaises(UnsupportedContentError):
         Message(self.message_json)
Exemplo n.º 16
0
 def test_init__invalid_json(self):
     with self.assertRaises(UnsupportedContentError):
         Message(self.message_json)
Exemplo n.º 17
0
 def test_init__message_with_forward(self, telepot):
     telepot.glance.return_value = 'text', 'private', 31416
     self.message_json['forward_from'] = None
     with self.assertRaises(UnsupportedContentError):
         Message(self.message_json)
Exemplo n.º 18
0
 def test_init__command_with_underscore(self, telepot):
     telepot.glance.return_value = 'text', 'private', 31416
     self.message_json['text'] = '/begin_chat here'
     message = Message(self.message_json)
     self.assertEqual(message.command, 'begin_chat')
     self.assertEqual(message.command_args, 'here')
Exemplo n.º 19
0
 def test_init__invalid_voice(self, telepot):
     telepot.glance.return_value = 'voice', 'private', 31416
     with self.assertRaises(UnsupportedContentError):
         Message(self.message_json)