~homeworkprod/byceps

90357856fb25b54d9e60125d1b658be3514449ae — Jochen Kupperschmidt a month ago 4d64fc3
Prepare login-based test with frozen time for Flask v2.x, Werkzeug v2.x
1 files changed, 13 insertions(+), 12 deletions(-)

M tests/integration/blueprints/admin/shop/order/test_order_export.py
M tests/integration/blueprints/admin/shop/order/test_order_export.py => tests/integration/blueprints/admin/shop/order/test_order_export.py +13 -12
@@ 27,14 27,7 @@ from tests.integration.services.shop.helpers import (
@pytest.fixture(scope='package')
def shop_order_admin(make_admin):
    permission_ids = {'admin.access', 'shop_order.view'}
    admin = make_admin('ShopOrderExportAdmin', permission_ids)
    login_user(admin.id)
    return admin


@pytest.fixture(scope='package')
def shop_order_admin_client(make_client, admin_app, shop_order_admin):
    return make_client(admin_app, user_id=shop_order_admin.id)
    return make_admin('ShopOrderExportAdmin', permission_ids)


@pytest.fixture


@@ 150,12 143,17 @@ def order(storefront, cart, orderer):


@freeze_time('2015-04-15 07:54:18')  # UTC
def test_serialize_existing_order(request, order, shop_order_admin_client):
def test_serialize_existing_order(
    request, admin_app, shop_order_admin, make_client, order
):
    filename = request.fspath.dirpath('order_export.xml')
    expected = filename.read_text('iso-8859-1').rstrip()

    login_user(shop_order_admin.id)
    client = make_client(admin_app, user_id=shop_order_admin.id)

    url = f'/admin/shop/orders/{order.id}/export'
    response = shop_order_admin_client.get(url)
    response = client.get(url)

    assert response.status_code == 200
    assert response.content_type == 'application/xml; charset=iso-8859-1'


@@ 165,11 163,14 @@ def test_serialize_existing_order(request, order, shop_order_admin_client):


@freeze_time('2015-04-15 07:54:18')  # UTC
def test_serialize_unknown_order(shop_order_admin_client):
def test_serialize_unknown_order(admin_app, shop_order_admin, make_client):
    unknown_order_id = '00000000-0000-0000-0000-000000000000'

    login_user(shop_order_admin.id)
    client = make_client(admin_app, user_id=shop_order_admin.id)

    url = f'/admin/shop/orders/{unknown_order_id}/export'
    response = shop_order_admin_client.get(url)
    response = client.get(url)

    assert response.status_code == 404