0001-misc-split-test-module-and-simplify-test-data.patch
tests/test_admin_pages.py | ||
---|---|---|
3047 | 3047 |
assert pub.cfg['misc']['default-position'] == '1.234;-1.234' |
3048 | 3048 | |
3049 | 3049 | |
3050 |
def test_wscalls_new(pub): |
|
3051 |
create_superuser(pub) |
|
3052 |
NamedWsCall.wipe() |
|
3053 |
app = login(get_app(pub)) |
|
3054 | ||
3055 |
# go to the page and cancel |
|
3056 |
resp = app.get('/backoffice/settings/wscalls/') |
|
3057 |
resp = resp.click('New webservice call') |
|
3058 |
resp = resp.forms[0].submit('cancel') |
|
3059 |
assert resp.location == 'http://example.net/backoffice/settings/wscalls/' |
|
3060 | ||
3061 |
# go to the page and add a webservice call |
|
3062 |
resp = app.get('/backoffice/settings/wscalls/') |
|
3063 |
resp = resp.click('New webservice call') |
|
3064 |
resp.form['name'] = 'a new webservice call' |
|
3065 |
resp.form['description'] = 'description' |
|
3066 |
resp.form['request$url'] = 'http://remote.example.net/json' |
|
3067 |
resp = resp.form.submit('submit') |
|
3068 |
assert resp.location == 'http://example.net/backoffice/settings/wscalls/' |
|
3069 |
resp = resp.follow() |
|
3070 |
assert 'a new webservice call' in resp.text |
|
3071 |
resp = resp.click('a new webservice call') |
|
3072 |
assert 'Webservice Call - a new webservice call' in resp.text |
|
3073 |
resp = resp.click('Edit') |
|
3074 |
assert 'Edit webservice call' in resp.text |
|
3075 | ||
3076 |
assert NamedWsCall.get('a_new_webservice_call').name == 'a new webservice call' |
|
3077 | ||
3078 | ||
3079 |
def test_wscalls_view(pub): |
|
3080 |
create_superuser(pub) |
|
3081 |
NamedWsCall.wipe() |
|
3082 | ||
3083 |
wscall = NamedWsCall(name='xxx') |
|
3084 |
wscall.description = 'description' |
|
3085 |
wscall.request = { |
|
3086 |
'url': 'http://remote.example.net/json', |
|
3087 |
'request_signature_key': 'xxx', |
|
3088 |
'qs_data': {'a': 'b'}, |
|
3089 |
'method': 'POST', |
|
3090 |
'post_data': {'c': 'd'}, |
|
3091 |
} |
|
3092 |
wscall.store() |
|
3093 | ||
3094 |
app = login(get_app(pub)) |
|
3095 |
resp = app.get('/backoffice/settings/wscalls/%s/' % wscall.id) |
|
3096 |
assert 'http://remote.example.net/json' in resp.text |
|
3097 | ||
3098 | ||
3099 |
def test_wscalls_edit(pub): |
|
3100 |
test_wscalls_view(pub) |
|
3101 | ||
3102 |
app = login(get_app(pub)) |
|
3103 | ||
3104 |
resp = app.get('/backoffice/settings/wscalls/xxx/') |
|
3105 |
resp = resp.click(href='edit') |
|
3106 |
assert resp.form['name'].value == 'xxx' |
|
3107 |
assert 'slug' in resp.form.fields |
|
3108 |
resp.form['description'] = 'bla bla bla' |
|
3109 |
resp = resp.form.submit('submit') |
|
3110 |
assert resp.location == 'http://example.net/backoffice/settings/wscalls/xxx/' |
|
3111 |
resp = resp.follow() |
|
3112 | ||
3113 |
assert NamedWsCall.get('xxx').description == 'bla bla bla' |
|
3114 | ||
3115 |
resp = app.get('/backoffice/settings/wscalls/xxx/') |
|
3116 |
resp = resp.click(href='edit') |
|
3117 |
assert resp.form['name'].value == 'xxx' |
|
3118 |
assert 'slug' in resp.form.fields |
|
3119 |
resp.form['slug'] = 'yyy' |
|
3120 |
resp = resp.form.submit('submit') |
|
3121 |
assert resp.location == 'http://example.net/backoffice/settings/wscalls/yyy/' |
|
3122 | ||
3123 | ||
3124 |
def test_wscalls_delete(pub): |
|
3125 |
test_wscalls_view(pub) |
|
3126 |
assert NamedWsCall.count() == 1 |
|
3127 | ||
3128 |
app = login(get_app(pub)) |
|
3129 | ||
3130 |
resp = app.get('/backoffice/settings/wscalls/xxx/') |
|
3131 |
resp = resp.click(href='delete') |
|
3132 |
resp = resp.form.submit('cancel') |
|
3133 |
assert resp.location == 'http://example.net/backoffice/settings/wscalls/' |
|
3134 | ||
3135 |
resp = app.get('/backoffice/settings/wscalls/xxx/') |
|
3136 |
resp = resp.click(href='delete') |
|
3137 |
resp = resp.form.submit('submit') |
|
3138 |
assert resp.location == 'http://example.net/backoffice/settings/wscalls/' |
|
3139 |
assert NamedWsCall.count() == 0 |
|
3140 | ||
3141 | ||
3142 | 3050 |
def test_settings_permissions(pub): |
3143 | 3051 |
create_superuser(pub) |
3144 | 3052 |
role1 = create_role() |
tests/test_wscalls_admin_pages.py | ||
---|---|---|
1 |
# -*- coding: utf-8 -*- |
|
2 | ||
3 |
import pytest |
|
4 | ||
5 |
from wcs.qommon.http_request import HTTPRequest |
|
6 |
from wcs.wscalls import NamedWsCall |
|
7 | ||
8 |
from utilities import get_app, login, create_temporary_pub, clean_temporary_pub |
|
9 |
from test_admin_pages import create_superuser |
|
10 | ||
11 | ||
12 |
def pytest_generate_tests(metafunc): |
|
13 |
if 'pub' in metafunc.fixturenames: |
|
14 |
metafunc.parametrize('pub', ['pickle', 'sql', 'pickle-templates'], indirect=True) |
|
15 | ||
16 | ||
17 |
@pytest.fixture |
|
18 |
def pub(request): |
|
19 |
pub = create_temporary_pub( |
|
20 |
sql_mode=bool('sql' in request.param), |
|
21 |
templates_mode=bool('templates' in request.param) |
|
22 |
) |
|
23 | ||
24 |
req = HTTPRequest(None, {'SCRIPT_NAME': '/', 'SERVER_NAME': 'example.net'}) |
|
25 |
pub.set_app_dir(req) |
|
26 |
pub.cfg['identification'] = {'methods': ['password']} |
|
27 |
pub.cfg['language'] = {'language': 'en'} |
|
28 |
pub.write_cfg() |
|
29 | ||
30 |
return pub |
|
31 | ||
32 | ||
33 |
def teardown_module(module): |
|
34 |
clean_temporary_pub() |
|
35 | ||
36 | ||
37 |
@pytest.fixture |
|
38 |
def wscall(): |
|
39 |
NamedWsCall.wipe() |
|
40 |
wscall = NamedWsCall(name='xxx') |
|
41 |
wscall.description = 'description' |
|
42 |
wscall.request = { |
|
43 |
'url': 'http://remote.example.net/json', |
|
44 |
'request_signature_key': 'xxx', |
|
45 |
'qs_data': {'a': 'b'}, |
|
46 |
'method': 'POST', |
|
47 |
'post_data': {'c': 'd'}, |
|
48 |
} |
|
49 |
wscall.store() |
|
50 |
return wscall |
|
51 | ||
52 | ||
53 |
def test_wscalls_new(pub): |
|
54 |
create_superuser(pub) |
|
55 |
NamedWsCall.wipe() |
|
56 |
app = login(get_app(pub)) |
|
57 | ||
58 |
# go to the page and cancel |
|
59 |
resp = app.get('/backoffice/settings/wscalls/') |
|
60 |
resp = resp.click('New webservice call') |
|
61 |
resp = resp.forms[0].submit('cancel') |
|
62 |
assert resp.location == 'http://example.net/backoffice/settings/wscalls/' |
|
63 | ||
64 |
# go to the page and add a webservice call |
|
65 |
resp = app.get('/backoffice/settings/wscalls/') |
|
66 |
resp = resp.click('New webservice call') |
|
67 |
resp.form['name'] = 'a new webservice call' |
|
68 |
resp.form['description'] = 'description' |
|
69 |
resp.form['request$url'] = 'http://remote.example.net/json' |
|
70 |
resp = resp.form.submit('submit') |
|
71 |
assert resp.location == 'http://example.net/backoffice/settings/wscalls/' |
|
72 |
resp = resp.follow() |
|
73 |
assert 'a new webservice call' in resp.text |
|
74 |
resp = resp.click('a new webservice call') |
|
75 |
assert 'Webservice Call - a new webservice call' in resp.text |
|
76 |
resp = resp.click('Edit') |
|
77 |
assert 'Edit webservice call' in resp.text |
|
78 | ||
79 |
assert NamedWsCall.get('a_new_webservice_call').name == 'a new webservice call' |
|
80 | ||
81 | ||
82 |
def test_wscalls_view(pub, wscall): |
|
83 |
create_superuser(pub) |
|
84 | ||
85 |
app = login(get_app(pub)) |
|
86 |
resp = app.get('/backoffice/settings/wscalls/%s/' % wscall.id) |
|
87 |
assert 'http://remote.example.net/json' in resp.text |
|
88 | ||
89 | ||
90 |
def test_wscalls_edit(pub, wscall): |
|
91 |
create_superuser(pub) |
|
92 | ||
93 |
app = login(get_app(pub)) |
|
94 | ||
95 |
resp = app.get('/backoffice/settings/wscalls/xxx/') |
|
96 |
resp = resp.click(href='edit') |
|
97 |
assert resp.form['name'].value == 'xxx' |
|
98 |
assert 'slug' in resp.form.fields |
|
99 |
resp.form['description'] = 'bla bla bla' |
|
100 |
resp = resp.form.submit('submit') |
|
101 |
assert resp.location == 'http://example.net/backoffice/settings/wscalls/xxx/' |
|
102 |
resp = resp.follow() |
|
103 | ||
104 |
assert NamedWsCall.get('xxx').description == 'bla bla bla' |
|
105 | ||
106 |
resp = app.get('/backoffice/settings/wscalls/xxx/') |
|
107 |
resp = resp.click(href='edit') |
|
108 |
assert resp.form['name'].value == 'xxx' |
|
109 |
assert 'slug' in resp.form.fields |
|
110 |
resp.form['slug'] = 'yyy' |
|
111 |
resp = resp.form.submit('submit') |
|
112 |
assert resp.location == 'http://example.net/backoffice/settings/wscalls/yyy/' |
|
113 | ||
114 | ||
115 |
def test_wscalls_delete(pub, wscall): |
|
116 |
create_superuser(pub) |
|
117 | ||
118 |
app = login(get_app(pub)) |
|
119 | ||
120 |
resp = app.get('/backoffice/settings/wscalls/xxx/') |
|
121 |
resp = resp.click(href='delete') |
|
122 |
resp = resp.form.submit('cancel') |
|
123 |
assert resp.location == 'http://example.net/backoffice/settings/wscalls/' |
|
124 | ||
125 |
resp = app.get('/backoffice/settings/wscalls/xxx/') |
|
126 |
resp = resp.click(href='delete') |
|
127 |
resp = resp.form.submit('submit') |
|
128 |
assert resp.location == 'http://example.net/backoffice/settings/wscalls/' |
|
129 |
assert NamedWsCall.count() == 0 |
|
0 |
- |