aboutsummaryrefslogtreecommitdiffstats
path: root/api/tests/test_deleted_messages.py
blob: cd5acab02513007e27f2e4186c97b37f5df217ea (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
from datetime import datetime

from django_hosts.resolvers import reverse

from .base import APISubdomainTestCase
from ..models import User


class DeletedMessagesTests(APISubdomainTestCase):
    @classmethod
    def setUpTestData(cls):  # noqa
        cls.author = User.objects.create(
            id=55,
            name='Robbie Rotten',
            discriminator=55,
            avatar_hash=None
        )

        cls.data = {
            'actor': None,
            'creation': datetime.utcnow().isoformat(),
            'deletedmessage_set': [
                {
                    'author': cls.author.id,
                    'id': 55,
                    'channel_id': 5555,
                    'content': "Terror Billy is a meanie",
                    'embeds': []
                },
                {
                    'author': cls.author.id,
                    'id': 56,
                    'channel_id': 5555,
                    'content': "If you purge this, you're evil",
                    'embeds': []
                }
            ]
        }

    def test_accepts_valid_data(self):
        url = reverse('bot:messagedeletioncontext-list', host='api')
        response = self.client.post(url, data=self.data)
        self.assertEqual(response.status_code, 201)