Completed
Push — main ( 4a33dd...b7acb4 )
by Jochen
03:55
created

admin()   A

Complexity

Conditions 1

Size

Total Lines 9
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 8
nop 1
dl 0
loc 9
rs 10
c 0
b 0
f 0
1
"""
2
:Copyright: 2006-2020 Jochen Kupperschmidt
3
:License: Modified BSD, see LICENSE for details.
4
"""
5
6
import pytest
7
8
import byceps.services.shop.shop.service as shop_service
9
10
from tests.helpers import http_client, login_user
11
12
13
@pytest.fixture(scope='module')
14
def admin(make_admin):
15
    permission_ids = {
16
        'admin.access',
17
        'shop.create',
18
    }
19
    admin = make_admin('ShopAdmin', permission_ids)
20
    login_user(admin.id)
21
    return admin
22
23
24
def test_create_shop(email_config, admin_app, admin):
25
    shop_id = 'acme'
26
    assert shop_service.find_shop(shop_id) is None
27
28
    url = '/admin/shop/shop/shops'
29
    form_data = {
30
        'id': shop_id,
31
        'title': 'ACME',
32
        'email_config_id': email_config.id,
33
    }
34
    with http_client(admin_app, user_id=admin.id) as client:
35
        response = client.post(url, data=form_data)
36
37
    shop = shop_service.find_shop(shop_id)
38
    assert shop is not None
39
    assert shop.id == shop_id
40
    assert shop.title == 'ACME'
41
    assert shop.email_config_id == email_config.id
42