1
|
|
|
""" |
2
|
|
|
:Copyright: 2006-2020 Jochen Kupperschmidt |
3
|
|
|
:License: Modified BSD, see LICENSE for details. |
4
|
|
|
""" |
5
|
|
|
|
6
|
|
|
import byceps.services.email.service as email_service |
7
|
|
|
|
8
|
|
|
from tests.helpers import http_client |
9
|
|
|
|
10
|
|
|
|
11
|
|
View Code Duplication |
def test_create_minimal_config(admin_app, email_admin): |
|
|
|
|
12
|
|
|
config_id = 'acme-minimal' |
13
|
|
|
assert email_service.find_config(config_id) is None |
14
|
|
|
|
15
|
|
|
url = '/admin/email/configs' |
16
|
|
|
form_data = { |
17
|
|
|
'config_id': config_id, |
18
|
|
|
'sender_address': '[email protected]', |
19
|
|
|
} |
20
|
|
|
with http_client(admin_app, user_id=email_admin.id) as client: |
21
|
|
|
response = client.post(url, data=form_data) |
22
|
|
|
|
23
|
|
|
config = email_service.find_config(config_id) |
24
|
|
|
assert config is not None |
25
|
|
|
assert config.id == config_id |
26
|
|
|
assert config.sender is not None |
27
|
|
|
assert config.sender.address == '[email protected]' |
28
|
|
|
assert config.sender.name is None |
29
|
|
|
assert config.contact_address is None |
30
|
|
|
|
31
|
|
|
|
32
|
|
View Code Duplication |
def test_create_full_config(admin_app, email_admin): |
|
|
|
|
33
|
|
|
config_id = 'acme-full' |
34
|
|
|
assert email_service.find_config(config_id) is None |
35
|
|
|
|
36
|
|
|
url = '/admin/email/configs' |
37
|
|
|
form_data = { |
38
|
|
|
'config_id': config_id, |
39
|
|
|
'sender_address': '[email protected]', |
40
|
|
|
'sender_name': 'ACME Corp.', |
41
|
|
|
'contact_address': '[email protected]', |
42
|
|
|
} |
43
|
|
|
with http_client(admin_app, user_id=email_admin.id) as client: |
44
|
|
|
response = client.post(url, data=form_data) |
45
|
|
|
|
46
|
|
|
config = email_service.find_config(config_id) |
47
|
|
|
assert config is not None |
48
|
|
|
assert config.id == config_id |
49
|
|
|
assert config.sender is not None |
50
|
|
|
assert config.sender.address == '[email protected]' |
51
|
|
|
assert config.sender.name == 'ACME Corp.' |
52
|
|
|
assert config.contact_address == '[email protected]' |
53
|
|
|
|