def test_get_raw_held_message(self): self.client.login(username='******', password='******') response = self.client.get( reverse('rest_held_message', args=['foo.example.com', '1']), {'raw': 'True'}) self.assertEqual(response.status_code, 200) email = message_from_bytes(response.content) self.assertIsNotNone(email)
def test_get_attachments_for_held_message(self): self.client.login(username='******', password='******') response = self.client.get( reverse('rest_held_message', args=['foo.example.com', '1'])) self.assertEqual(response.status_code, 200) attachment_uri = json.loads(response.content.decode( 'utf-8'))['attachments'][0][0] # noqa: E501 # Now we will get this attachment. response = self.client.get(attachment_uri) self.assertEqual(response.status_code, 200) self.assertTrue('BEGIN PGP SIGNATURE' in str(response.content))
def test_get_held_message(self): self.client.login(username='******', password='******') response = self.client.get( reverse('rest_held_message', args=['foo.example.com', '1'])) self.assertEqual(response.status_code, 200) content = json.loads(response.content.decode('utf-8')) self.assertEqual(sorted(list(content.keys())), [ 'attachments', 'hold_date', 'msg', 'msgid', 'reason', 'sender', 'subject' ]) # noqa self.assertEqual(content['msgid'], 1) self.assertEqual(len(content['attachments']), 1) attachment_uri = content['attachments'][0] # Now we will get this attachment. self.client.get(attachment_uri)