Example #1
0
class RecipientPostShortMessageTests(unittest.TestCase):
    @mock.patch('groupy.api.endpoint.Endpoint')
    def setUp(self, mock_endpoint):
        self.recipient = Recipient(mock_endpoint(), 'm', 'i',
                                                    i='idkey', m='mkey')
        self.recipient.post('test message')
        self.mock_create = self.recipient._endpoint.create

    def test_post_short_message_calls_endpoint_once(self):
        self.assertEqual(self.mock_create.call_count, 1)

    def test_post_short_message_calls_endpoint_with_id_key(self):
        self.mock_create.assert_called_with('idkey', 'test message')
Example #2
0
class RecipientPostShortMessageTests(unittest.TestCase):
    @mock.patch('groupy.api.endpoint.Endpoint')
    def setUp(self, mock_endpoint):
        self.recipient = Recipient(mock_endpoint(),
                                   'm',
                                   'i',
                                   i='idkey',
                                   m='mkey')
        self.recipient.post('test message')
        self.mock_create = self.recipient._endpoint.create

    def test_post_short_message_calls_endpoint_once(self):
        self.assertEqual(self.mock_create.call_count, 1)

    def test_post_short_message_calls_endpoint_with_id_key(self):
        self.mock_create.assert_called_with('idkey', 'test message')
Example #3
0
class RecipientPostLongMessageTests(unittest.TestCase):
    @mock.patch('groupy.api.endpoint.Endpoint')
    def setUp(self, mock_endpoint):
        # TODO: Fix this literal dependency!
        self.chunks = ('x' * 1000, 'x' * 100)
        self.recipient = Recipient(mock_endpoint(), 'm', 'i',
                                                    i='idkey', m='mkey')
        self.recipient.post(''.join(self.chunks))
        self.mock_create = self.recipient._endpoint.create

    def test_post_long_message_calls_endpoint_twice(self):
        self.assertEqual(self.mock_create.call_count, 2)

    def test_post_long_message_calls_endpoint_with_each_chunk(self):
        calls = [call('idkey', self.chunks[0]), call('idkey', self.chunks[1])]
        self.mock_create.assert_has_calls(calls)
Example #4
0
class RecipientPostLongMessageTests(unittest.TestCase):
    @mock.patch('groupy.api.endpoint.Endpoint')
    def setUp(self, mock_endpoint):
        # TODO: Fix this literal dependency!
        self.chunks = ('x' * 1000, 'x' * 100)
        self.recipient = Recipient(mock_endpoint(),
                                   'm',
                                   'i',
                                   i='idkey',
                                   m='mkey')
        self.recipient.post(''.join(self.chunks))
        self.mock_create = self.recipient._endpoint.create

    def test_post_long_message_calls_endpoint_twice(self):
        self.assertEqual(self.mock_create.call_count, 2)

    def test_post_long_message_calls_endpoint_with_each_chunk(self):
        calls = [call('idkey', self.chunks[0]), call('idkey', self.chunks[1])]
        self.mock_create.assert_has_calls(calls)