Passed
Push — main ( a21473...138f92 )
by Jochen
04:19
created

tickets()   A

Complexity

Conditions 2

Size

Total Lines 7
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 6
nop 3
dl 0
loc 7
rs 10
c 0
b 0
f 0
1
"""
2
:Copyright: 2006-2021 Jochen Kupperschmidt
3
:License: Revised BSD (see `LICENSE` file for details)
4
"""
5
6
import pytest
7
8
from byceps.services.ticketing import ticket_creation_service
9
10
11
def test_get_sale_stats(party, tickets, api_client, api_client_authz_header):
12
    url = f'/api/v1/ticketing/sale_stats/{party.id}'
13
    headers = [api_client_authz_header]
14
15
    response = api_client.get(url, headers=headers)
16
17
    assert response.status_code == 200
18
    assert response.content_type == 'application/json'
19
    assert response.get_json() == {
20
        'tickets_max': 1348,
21
        'tickets_sold': 5,
22
    }
23
24
25
@pytest.fixture(scope='session')
26
def party(brand, make_party):
27
    party_id = 'for-the-stats'
28
    return make_party(
29
        brand.id, party_id, title=party_id, max_ticket_quantity=1348
30
    )
31
32
33
@pytest.fixture
34
def tickets(party, make_ticket_category, user):
35
    category = make_ticket_category(party.id, 'Normal')
36
    quantity = 5
37
38
    for i in range(quantity):
39
        ticket_creation_service.create_ticket(party.id, category.id, user.id)
40