forked from canada-ca/tracker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_is_admin_query.py
More file actions
50 lines (40 loc) · 1011 Bytes
/
test_is_admin_query.py
File metadata and controls
50 lines (40 loc) · 1011 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import logging
import pytest
from pytest import fail
from db import DB
from models import Users
from tests.test_functions import run, json
@pytest.fixture
def save():
save, cleanup, session = DB()
yield save
cleanup()
def test_is_admin_query(save, caplog):
"""
Test to see if query works
"""
user = Users(
display_name="testuser",
user_name="testuser@testemail.ca",
password="testpassword123",
)
save(user)
caplog.set_level(logging.INFO)
result = run(
query="""
{
isUserAdmin{
isAdmin
}
}
""",
as_user=user,
)
if "errors" in result:
fail("expected to retrieve true isAdmin. Instead:" "{}".format(json(result)))
expected_result = {"data": {"isUserAdmin": {"isAdmin": True}}}
assert result == expected_result
assert (
f"User: {user.id} checked for any admin roles, and found at least one."
in caplog.text
)