Skip to content

Commit 695282b

Browse files
committed
TestLogin.test_login_example: also test JSON content type
1 parent 4f09720 commit 695282b

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

components/tools/OmeroWeb/test/integration/test_api_login.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,9 @@ def test_login_errors(self, credentials, content_type):
176176
assert rsp.status_code == 403
177177
assert rsp.json()['message'] == message
178178

179-
def test_login_example(self):
179+
@pytest.mark.parametrize("content_type", (
180+
MULTIPART_CONTENT, "application/json"))
181+
def test_login_example(self, content_type):
180182
"""
181183
Example of successful login as user would do for real,
182184
starting at base url and getting all other urls and info from there.
@@ -224,10 +226,13 @@ def test_login_example(self):
224226
'server': server_id,
225227
# 'csrfmiddlewaretoken': token,
226228
}
227-
login_rsp = django_client.post(login_url, data)
228-
login_json = json.loads(login_rsp.content)
229-
assert login_json['success']
230-
event_context = login_json['eventContext']
229+
login_rsp = django_client.post(
230+
login_url,
231+
data,
232+
content_type=content_type)
233+
assert login_rsp.status_code == 200
234+
assert login_rsp.json()['success']
235+
event_context = login_rsp.json()['eventContext']
231236
# eventContext gives a bunch of info
232237
member_of_groups = event_context['memberOfGroups']
233238
current_group = event_context['groupId']

0 commit comments

Comments
 (0)