test_rslogging.py - test the logging API
Imports
These are listed in the order prescribed by PEP 8.
Standard library
Third-party imports
Local application imports
Tests
def test_main(test_client_app):
with test_client_app as client:
response = client.get("/")
assert response.status_code == 200
def test_add_log(test_client_app):
item = dict(
event="page",
act="view",
div_id="/runestone/fopp/index.html",
sid="testuser",
course_name="fopp",
timestamp=datetime.datetime.utcnow().isoformat(),
)
with test_client_app as client:
response = client.post(
"/logger/bookevent",
headers={"Content-type": "application/json; charset=utf-8"},
json=item,
)
assert response.status_code == 401
assert response.json()[“result”] == “success”
Create JWT security token add to headers
assert response.json()[“result”] == “success”
TODO: get login working and add a test for a logged in user
res = response.json() assert res[“correct”] is True assert res[“div_id”] == “test_mchoice_1”
The sid Column has a max length of 512. This should fail validation.
Create JWT security token add to headers