Passed
Push — master ( f1fa6b...b933ea )
by Jochen
02:27
created

match()   A

Complexity

Conditions 1

Size

Total Lines 3
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
nop 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
"""
2
:Copyright: 2006-2019 Jochen Kupperschmidt
3
:License: Modified BSD, see LICENSE for details.
4
"""
5
6
import pytest
7
8
from byceps.services.tourney import match_comment_service, match_service
9
10
11
def test_view_for_match_as_json(api_client, api_client_authz_header, match, comment):
12
    url = f'/api/tourney/matches/{match.id}/comments.json'
13
    headers = [api_client_authz_header]
14
15
    response = api_client.get(url, headers=headers)
16
    assert response.status_code == 200
17
    assert response.content_type == 'application/json'
18
    assert response.get_json() == {
19
        'comments': [
20
            {
21
                'comment_id': str(comment.id),
22
                'match_id': str(comment.match_id),
23
                'created_at': comment.created_at.isoformat(),
24
                'creator': {
25
                    'user_id': str(comment.creator.id),
26
                    'screen_name': comment.creator.screen_name,
27
                    'suspended': False,
28
                    'deleted': False,
29
                    'avatar_url': None,
30
                    'is_orga': False,
31
                },
32
                'body': 'Denn man tau.',
33
                'hidden': False,
34
                'hidden_at': None,
35
                'hidden_by_id': None,
36
            },
37
        ],
38
    }
39
40
41
# helpers
42
43
44
@pytest.fixture
45
def match(app):
46
    return match_service.create_match()
47
48
49
@pytest.fixture
50
def comment(app, match, user):
51
   return match_comment_service.create_comment(match.id, user.id, 'Denn man tau.')
52