~homeworkprod/byceps

c329485b53aca193fb409709b8bef586ffb5a224 — Jochen Kupperschmidt 1 year, 5 months ago 7d372d9
Rework domain name occurences in tests
M config/test_admin.py => config/test_admin.py +1 -1
@@ 1,7 1,7 @@
# an admin site configuration file to be used in tests

SECRET_KEY = b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
SERVER_NAME = 'example.com'
SERVER_NAME = 'admin.acmecon.test'
SESSION_COOKIE_SECURE = True
TESTING = True


M config/test_party.py => config/test_party.py +1 -1
@@ 1,7 1,7 @@
# a party site configuration file to be used in tests

SECRET_KEY = b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
SERVER_NAME = 'example.com'
SERVER_NAME = 'www.acmecon.test'
SESSION_COOKIE_SECURE = True
TESTING = True


M testfixtures/shop/order_export.xml => testfixtures/shop/order_export.xml +1 -1
@@ 35,7 35,7 @@
								<COUNTRY>DE</COUNTRY>
								<PHONE/>
								<FAX/>
								<EMAIL>h-w.mustermann@example.com</EMAIL>
								<EMAIL>h-w.mustermann@users.test</EMAIL>
							</ADDRESS>
						</PARTY>
					</INVOICE_PARTY>

M testfixtures/user.py => testfixtures/user.py +1 -1
@@ 31,7 31,7 @@ def create_user(
        created_at = datetime.utcnow()

    if not email_address:
        email_address = f'user{user_id}@example.com'
        email_address = f'user{user_id}@users.test'

    user = user_creation_service.build_user(
        created_at, screen_name, email_address

M tests/api/conftest.py => tests/api/conftest.py +1 -0
@@ 21,6 21,7 @@ def app(admin_app, data_path):
    config_overrides = {
        'API_TOKEN': API_TOKEN,
        CONFIG_PATH_DATA_KEY: data_path,
        'SERVER_NAME': 'api.acmecon.test',
    }
    app = create_admin_app(config_overrides)
    with app.app_context():

M tests/api/v1/user_avatar/test_avatar_url_by_email_address_hash.py => tests/api/v1/user_avatar/test_avatar_url_by_email_address_hash.py +5 -5
@@ 13,7 13,7 @@ from byceps.util.image.models import ImageType


def test_existent_user_with_avatar(api_client):
    email_address = 'user1@example.com'
    email_address = 'user1@users.test'
    user_id = create_initialized_user('UserWithAvatar', email_address)
    avatar_id = set_avatar(user_id)
    email_address_hash = hash_email_address(email_address)


@@ 23,18 23,18 @@ def test_existent_user_with_avatar(api_client):
    assert response.status_code == 302
    assert_redirect(
        response,
        f'http://example.com/data/global/users/avatars/{avatar_id}.jpeg',
        f'http://api.acmecon.test/data/global/users/avatars/{avatar_id}.jpeg',
    )


def test_existent_user_without_avatar(api_client):
    email_address = 'user2@example.com'
    email_address = 'user2@users.test'
    user_id = create_initialized_user('UserWithoutAvatar', email_address)
    email_address_hash = hash_email_address(email_address)

    response = send_request(api_client, email_address_hash)

    assert_redirect(response, 'http://example.com/static/avatar_fallback.svg')
    assert_redirect(response, 'http://api.acmecon.test/static/avatar_fallback.svg')


def test_unrecognized_hash(api_client):


@@ 42,7 42,7 @@ def test_unrecognized_hash(api_client):

    response = send_request(api_client, unrecognized_email_address_hash)

    assert_redirect(response, 'http://example.com/static/avatar_fallback.svg')
    assert_redirect(response, 'http://api.acmecon.test/static/avatar_fallback.svg')


# helpers

M tests/blueprints/admin/newsletter/test_views.py => tests/blueprints/admin/newsletter/test_views.py +7 -7
@@ 30,7 30,7 @@ def test_export_subscribers(newsletter_list, subscribers, client):
        'subscribers': [
            {
                'screen_name': 'User-1',
                'email_address': 'user001@example.com',
                'email_address': 'user001@users.test',
            },

            # User #2 has declined a subscription, and thus should be


@@ 42,7 42,7 @@ def test_export_subscribers(newsletter_list, subscribers, client):
            # subscription, so it should be included.
            {
                'screen_name': 'User-4',
                'email_address': 'user004@example.com',
                'email_address': 'user004@users.test',
            },

            # User #5 has initially requested, but later declined a


@@ 50,7 50,7 @@ def test_export_subscribers(newsletter_list, subscribers, client):

            {
                'screen_name': 'User-6',
                'email_address': 'user006@example.com',
                'email_address': 'user006@users.test',
            },

            # User #7 has been suspended and should be excluded, regardless


@@ 71,13 71,13 @@ def test_export_subscribers(newsletter_list, subscribers, client):

def test_export_subscriber_email_addresses(newsletter_list, subscribers, client):
    expected_data = '\n'.join([
        'user001@example.com',
        'user001@users.test',
        # User #2 has declined a subscription.
        # User #3 is not initialized.
        # User #4 has initially declined, but later requested a subscription.
        'user004@example.com',
        'user004@users.test',
        # User #5 has initially requested, but later declined a subscription.
        'user006@example.com',
        'user006@users.test',
        # User #7 has been suspended, and thus should be excluded.
        # User #8 has been deleted, and thus should be excluded.
    ]).encode('utf-8')


@@ 141,7 141,7 @@ def subscribers(newsletter_list):
    ]:
        user = create_user(
            screen_name=f'User-{number:d}',
            email_address=f'user{number:03d}@example.com',
            email_address=f'user{number:03d}@users.test',
            initialized=initialized,
            suspended=suspended,
            deleted=deleted,

M tests/blueprints/admin/shop/order/test_order_export.py => tests/blueprints/admin/shop/order/test_order_export.py +1 -1
@@ 113,7 113,7 @@ def cart(article_bungalow, article_guest_fee, article_table):
@pytest.fixture
def _orderer(make_user):
    yield from make_user(
        'Besteller', email_address='h-w.mustermann@example.com'
        'Besteller', email_address='h-w.mustermann@users.test'
    )



M tests/blueprints/authentication/test_views_password_update.py => tests/blueprints/authentication/test_views_password_update.py +1 -1
@@ 44,7 44,7 @@ def test_when_logged_in_endpoint_is_available(party_app, site, user):
    response = send_request(party_app, form_data, user_id=user.id)

    assert response.status_code == 302
    assert response.headers.get('Location') == 'http://example.com/authentication/login'
    assert response.headers.get('Location') == 'http://www.acmecon.test/authentication/login'

    credential_after = find_credential(user.id)
    session_token_after = find_session_token(user.id)

M tests/blueprints/site/shop/order/test_views.py => tests/blueprints/site/shop/order/test_views.py +2 -2
@@ 128,7 128,7 @@ def test_order(
    )
    order_placed_mock.assert_called_once_with(None, event=event)

    order_detail_page_url = f'http://example.com/shop/orders/{order.id}'
    order_detail_page_url = f'http://www.acmecon.test/shop/orders/{order.id}'

    assert_response_headers(response, order_detail_page_url)



@@ 188,7 188,7 @@ def test_order_single(
    )
    order_placed_mock.assert_called_once_with(None, event=event)

    order_detail_page_url = f'http://example.com/shop/orders/{order.id}'
    order_detail_page_url = f'http://www.acmecon.test/shop/orders/{order.id}'

    assert_response_headers(response, order_detail_page_url)


M tests/blueprints/site/user_message/test_address_formatting.py => tests/blueprints/site/user_message/test_address_formatting.py +3 -3
@@ 28,9 28,9 @@ def test_recipient_formatting(site, params):


@pytest.fixture(params=[
    ('Alice', 'alice@example.com', 'Alice <alice@example.com>'),
    ('<AngleInvestor>', 'angleinvestor@example.com', '"<AngleInvestor>" <angleinvestor@example.com>'),
    ('-=]YOLO[=-', 'yolo@example.com', '"-=]YOLO[=-" <yolo@example.com>'),
    ('Alice', 'alice@users.test', 'Alice <alice@users.test>'),
    ('<AngleInvestor>', 'angleinvestor@users.test', '"<AngleInvestor>" <angleinvestor@users.test>'),
    ('-=]YOLO[=-', 'yolo@users.test', '"-=]YOLO[=-" <yolo@users.test>'),
])
def params(request):
    yield request.param

M tests/blueprints/site/user_message/test_send.py => tests/blueprints/site/user_message/test_send.py +21 -21
@@ 17,11 17,11 @@ from tests.helpers import create_site, create_user, http_client, login_user
def site1(party_app, make_email_config):
    email_config = make_email_config(
        'acme-noreply',
        sender_address='noreply@example.com',
        sender_address='noreply@acmecon.test',
        sender_name='ACME Entertainment Convention',
    )
    site = create_site(
        server_name='acme.example.com', email_config_id=email_config.id
        server_name='www.acmecon.test', email_config_id=email_config.id
    )
    yield site
    site_service.delete_site(site.id)


@@ 31,12 31,12 @@ def site1(party_app, make_email_config):
def site2(party_app, make_email_config):
    email_config = make_email_config(
        'acme-noreply-with-contact-address',
        sender_address='noreply@example.com',
        sender_address='noreply@acmecon.test',
        sender_name='ACME Entertainment Convention',
        contact_address='help@example.com',
        contact_address='help@acmecon.test',
    )
    site = create_site(
        server_name='acme.example.com', email_config_id=email_config.id
        server_name='www.acmecon.test', email_config_id=email_config.id
    )
    yield site
    site_service.delete_site(site.id)


@@ 47,7 47,7 @@ def user_alice(party_app):
    user = create_user(
        'Alice',
        user_id='a4903d8f-0bc6-4af9-aeb9-d7534a0a22e8',
        email_address='alice@example.com',
        email_address='alice@users.test',
    )
    yield user
    user_command_service.delete_account(user.id, user.id, 'clean up')


@@ 58,7 58,7 @@ def user_bob(party_app):
    user = create_user(
        'Bob',
        user_id='11d72bab-3646-4199-b96c-e5e4c6f972bc',
        email_address='bob@example.com',
        email_address='bob@users.test',
    )
    yield user
    user_command_service.delete_account(user.id, user.id, 'clean up')


@@ 79,19 79,19 @@ kthxbye,
Alice
'''

    expected_response_location = f'http://example.com/users/{recipient.id}'
    expected_response_location = f'http://www.acmecon.test/users/{recipient.id}'

    expected_email_sender = (
        'ACME Entertainment Convention <noreply@example.com>'
        'ACME Entertainment Convention <noreply@acmecon.test>'
    )
    expected_email_recipients = ['Bob <bob@example.com>']
    expected_email_subject = 'Mitteilung von Alice (über acme.example.com)'
    expected_email_recipients = ['Bob <bob@users.test>']
    expected_email_subject = 'Mitteilung von Alice (über www.acmecon.test)'
    expected_email_body = '''\
Hallo Bob,

Alice möchte dir die folgende Mitteilung zukommen lassen.

Du kannst Alice hier antworten: http://example.com/user_messages/to/a4903d8f-0bc6-4af9-aeb9-d7534a0a22e8/create
Du kannst Alice hier antworten: http://www.acmecon.test/user_messages/to/a4903d8f-0bc6-4af9-aeb9-d7534a0a22e8/create

ACHTUNG: Antworte *nicht* auf diese E-Mail, sondern folge dem Link.



@@ 107,7 107,7 @@ Alice
---8<-------------------------------------

-- 
Diese Mitteilung wurde über die Website acme.example.com gesendet.\
Diese Mitteilung wurde über die Website www.acmecon.test gesendet.\
'''

    response = send_request(


@@ 140,19 140,19 @@ Best,
Bob
'''

    expected_response_location = f'http://example.com/users/{recipient.id}'
    expected_response_location = f'http://www.acmecon.test/users/{recipient.id}'

    expected_email_sender = (
        'ACME Entertainment Convention <noreply@example.com>'
        'ACME Entertainment Convention <noreply@acmecon.test>'
    )
    expected_email_recipients = ['Alice <alice@example.com>']
    expected_email_subject = 'Mitteilung von Bob (über acme.example.com)'
    expected_email_recipients = ['Alice <alice@users.test>']
    expected_email_subject = 'Mitteilung von Bob (über www.acmecon.test)'
    expected_email_body = '''\
Hallo Alice,

Bob möchte dir die folgende Mitteilung zukommen lassen.

Du kannst Bob hier antworten: http://example.com/user_messages/to/11d72bab-3646-4199-b96c-e5e4c6f972bc/create
Du kannst Bob hier antworten: http://www.acmecon.test/user_messages/to/11d72bab-3646-4199-b96c-e5e4c6f972bc/create

ACHTUNG: Antworte *nicht* auf diese E-Mail, sondern folge dem Link.



@@ 168,8 168,8 @@ Bob
---8<-------------------------------------

-- 
Diese Mitteilung wurde über die Website acme.example.com gesendet.
Bei Fragen kontaktiere uns bitte per E-Mail an: help@example.com\
Diese Mitteilung wurde über die Website www.acmecon.test gesendet.
Bei Fragen kontaktiere uns bitte per E-Mail an: help@acmecon.test\
'''

    response = send_request(


@@ 194,7 194,7 @@ def test_send_when_not_logged_in(party_app, site1):
    response = send_request(party_app, recipient_id, text)

    assert response.status_code == 302
    assert response.location == 'http://example.com/authentication/login'
    assert response.location == 'http://www.acmecon.test/authentication/login'


# helpers

M tests/blueprints/user/test_views_create.py => tests/blueprints/user/test_views_create.py +3 -3
@@ 42,7 42,7 @@ def user_admin(make_user):
@pytest.fixture(scope='module')
def site(party_app, make_email_config, party):
    email_config = make_email_config(
        'example-noreply', sender_address='noreply@example.com'
        'acmecon-noreply', sender_address='noreply@acmecon.test'
    )
    site = create_site(email_config_id=email_config.id, party_id=party.id)
    yield site


@@ 182,13 182,13 @@ def test_create(
    verification_token = find_verification_token(user.id)
    assert verification_token is not None

    expected_sender = 'noreply@example.com'
    expected_sender = 'noreply@acmecon.test'
    expected_recipients = ['hiro@metaverse.org']
    expected_subject = 'Hiro, bitte bestätige deine E-Mail-Adresse'
    expected_body = f'''
Hallo Hiro,

bitte bestätige deine E-Mail-Adresse, indem du diese URL abrufst: https://www.example.com/users/email_address/confirmation/{verification_token.token}
bitte bestätige deine E-Mail-Adresse, indem du diese URL abrufst: https://www.acmecon.test/users/email_address/confirmation/{verification_token.token}
    '''.strip()

    send_email_mock.assert_called_once_with(

M tests/conftest.py => tests/conftest.py +1 -1
@@ 143,7 143,7 @@ def make_email_config(admin_app):
@pytest.fixture(scope='module')
def email_config(make_email_config):
    return make_email_config(
        DEFAULT_EMAIL_CONFIG_ID, sender_address='info@shop.example'
        DEFAULT_EMAIL_CONFIG_ID, sender_address='info@acmecon.test'
    )



M tests/helpers.py => tests/helpers.py +1 -1
@@ 106,7 106,7 @@ def create_site(
    *,
    site_id='acmecon-2014-website',
    title='Website',
    server_name='www.example.com',
    server_name='www.acmecon.test',
    email_config_id=DEFAULT_EMAIL_CONFIG_ID,
    party_id=None,
    enabled=True,

M tests/services/news/test_models.py => tests/services/news/test_models.py +1 -1
@@ 19,7 19,7 @@ def editor(make_user):
@pytest.fixture(scope='module')
def channel(brand):
    channel_id = f'{brand.id}-test'
    url_prefix = 'https://example.com/news/'
    url_prefix = 'https://www.acmecon.test/news/'

    channel = news_channel_service.create_channel(brand.id, channel_id, url_prefix)


M tests/services/shop/order/email/test_email_on_order_canceled.py => tests/services/shop/order/email/test_email_on_order_canceled.py +5 -5
@@ 23,7 23,7 @@ from .base import place_order_with_items
@pytest.fixture
def customer(party_app):
    user = create_user_with_detail(
        'Versager', email_address='versager@example.com'
        'Versager', email_address='versager@users.test'
    )
    user_id = user.id
    yield user


@@ 61,8 61,8 @@ def test_email_on_order_canceled(
    with current_user_set(app, customer), app.app_context():
        order_email_service.send_email_for_canceled_order_to_orderer(order.id)

    expected_sender = 'info@shop.example'
    expected_recipients = ['versager@example.com']
    expected_sender = 'info@acmecon.test'
    expected_recipients = ['versager@users.test']
    expected_subject = '\u274c Deine Bestellung (AC-14-B00017) wurde storniert.'
    expected_body = '''
Hallo Versager,


@@ 79,7 79,7 @@ das Team der Acme Entertainment Convention
-- 
Acme Entertainment Convention

E-Mail: acmecon@example.com
E-Mail: info@acmecon.test
    '''.strip()

    send_email_mock.assert_called_once_with(


@@ 104,6 104,6 @@ das Team der Acme Entertainment Convention
-- 
Acme Entertainment Convention

E-Mail: acmecon@example.com
E-Mail: info@acmecon.test
''',
    )

M tests/services/shop/order/email/test_email_on_order_paid.py => tests/services/shop/order/email/test_email_on_order_paid.py +5 -5
@@ 24,7 24,7 @@ from .base import place_order_with_items
@pytest.fixture
def customer(party_app):
    user = create_user_with_detail(
        'Vorbild', email_address='vorbild@example.com'
        'Vorbild', email_address='vorbild@users.test'
    )
    user_id = user.id
    yield user


@@ 63,8 63,8 @@ def test_email_on_order_paid(
    with current_user_set(app, customer), app.app_context():
        order_email_service.send_email_for_paid_order_to_orderer(order.id)

    expected_sender = 'info@shop.example'
    expected_recipients = ['vorbild@example.com']
    expected_sender = 'info@acmecon.test'
    expected_recipients = ['vorbild@users.test']
    expected_subject = (
        '\u2705 Deine Bestellung (AC-14-B00022) ist bezahlt worden.'
    )


@@ 83,7 83,7 @@ das Team der Acme Entertainment Convention
-- 
Acme Entertainment Convention

E-Mail: acmecon@example.com
E-Mail: info@acmecon.test
    '''.strip()

    send_email_mock.assert_called_once_with(


@@ 108,6 108,6 @@ das Team der Acme Entertainment Convention
-- 
Acme Entertainment Convention

E-Mail: acmecon@example.com
E-Mail: info@acmecon.test
''',
    )

M tests/services/shop/order/email/test_email_on_order_placed.py => tests/services/shop/order/email/test_email_on_order_placed.py +7 -7
@@ 28,7 28,7 @@ from .base import place_order_with_items
@pytest.fixture
def customer(party_app):
    user = create_user_with_detail(
        'Interessent', email_address='interessent@example.com'
        'Interessent', email_address='interessent@users.test'
    )
    user_id = user.id
    yield user


@@ 104,8 104,8 @@ def test_email_on_order_placed(send_email_mock, party_app, customer, order):
    with current_user_set(app, customer), app.app_context():
        order_email_service.send_email_for_incoming_order_to_orderer(order.id)

    expected_to_orderer_sender = 'info@shop.example'
    expected_to_orderer_recipients = ['interessent@example.com']
    expected_to_orderer_sender = 'info@acmecon.test'
    expected_to_orderer_recipients = ['interessent@users.test']
    expected_to_orderer_subject = (
        'Deine Bestellung (AC-14-B00253) ist eingegangen.'
    )


@@ 136,7 136,7 @@ Bitte überweise den Gesamtbetrag auf folgendes Konto:

Wir werden dich informieren, sobald wir deine Zahlung erhalten haben.

Hier kannst du deine Bestellungen einsehen: https://www.example.com/shop/orders
Hier kannst du deine Bestellungen einsehen: https://www.acmecon.test/shop/orders

Für Fragen stehen wir gerne zur Verfügung.



@@ 146,7 146,7 @@ das Team der Acme Entertainment Convention
-- 
Acme Entertainment Convention

E-Mail: acmecon@example.com
E-Mail: info@acmecon.test
    '''.strip()

    send_email_mock.assert_called_once_with(


@@ 176,7 176,7 @@ Bitte überweise den Gesamtbetrag auf folgendes Konto:

Wir werden dich informieren, sobald wir deine Zahlung erhalten haben.

Hier kannst du deine Bestellungen einsehen: https://www.example.com/shop/orders
Hier kannst du deine Bestellungen einsehen: https://www.acmecon.test/shop/orders
''',
    )



@@ 195,7 195,7 @@ das Team der Acme Entertainment Convention
-- 
Acme Entertainment Convention

E-Mail: acmecon@example.com
E-Mail: info@acmecon.test
''',
    )


M tests/services/user/test_change_email_address.py => tests/services/user/test_change_email_address.py +4 -4
@@ 11,8 11,8 @@ from tests.helpers import create_user


def test_change_email_address_with_reason(admin_app, admin_user):
    old_email_address = 'zero-cool@example.com'
    new_email_address = 'crash.override@example.com'
    old_email_address = 'zero-cool@users.test'
    new_email_address = 'crash.override@users.test'
    reason = 'Does not want to be recognized by Acid Burn.'

    user_id = create_user(


@@ 60,8 60,8 @@ def test_change_email_address_with_reason(admin_app, admin_user):


def test_change_email_address_without_reason(admin_app, admin_user):
    old_email_address = 'address_with_tyop@example.com'
    new_email_address = 'address_without_typo@example.com'
    old_email_address = 'address_with_tyop@users.test'
    new_email_address = 'address_without_typo@users.test'

    user_id = create_user(
        'WantsEmailAddressChangedWithoutReason',

M tests/services/user/test_delete_account.py => tests/services/user/test_delete_account.py +1 -1
@@ 39,7 39,7 @@ def role(permission):
def test_delete_account(admin_app, permission, role, admin_user):
    user_id = UUID('20868b15-b935-40fc-8054-38854ef8509a')
    screen_name = 'GetRidOfMe'
    email_address = 'timedout@example.net'
    email_address = 'timedout@users.test'
    legacy_id = 22299

    user = create_user_with_detail(

M tests/unit/services/email/test_sender_format.py => tests/unit/services/email/test_sender_format.py +3 -3
@@ 11,9 11,9 @@ from testfixtures.user import create_user_with_detail


@pytest.mark.parametrize('address, name, expected', [
    ('unnamed@example.com', None, 'unnamed@example.com'),
    ('simple@example.com', 'Simple', 'Simple <simple@example.com>'),
    ('mr.pink@example.com', 'Mr. Pink', '"Mr. Pink" <mr.pink@example.com>'),  # quotes name
    ('unnamed@users.test', None, 'unnamed@users.test'),
    ('simple@users.test', 'Simple', 'Simple <simple@users.test>'),
    ('mr.pink@users.test', 'Mr. Pink', '"Mr. Pink" <mr.pink@users.test>'),  # quotes name
])
def test_sender_format(address, name, expected):
    sender = Sender(address, name)