2016-04-27 10:27:05 +01:00
|
|
|
import json
|
2021-03-10 13:55:06 +00:00
|
|
|
|
2021-08-04 15:12:09 +01:00
|
|
|
from tests import create_admin_authorization_header
|
2016-04-27 10:27:05 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_create_event(notify_api):
|
|
|
|
|
with notify_api.test_request_context():
|
|
|
|
|
with notify_api.test_client() as client:
|
|
|
|
|
data = {
|
2023-08-29 14:54:30 -07:00
|
|
|
"event_type": "sucessful_login",
|
|
|
|
|
"data": {"something": "random", "in_fact": "could be anything"},
|
2016-04-27 10:27:05 +01:00
|
|
|
}
|
2023-08-29 14:54:30 -07:00
|
|
|
path = "/events"
|
2021-08-04 15:12:09 +01:00
|
|
|
auth_header = create_admin_authorization_header()
|
2023-08-29 14:54:30 -07:00
|
|
|
headers = [("Content-Type", "application/json"), auth_header]
|
|
|
|
|
response = client.post(path, data=json.dumps(data), headers=headers)
|
2016-04-27 10:27:05 +01:00
|
|
|
assert response.status_code == 201
|
2023-08-29 14:54:30 -07:00
|
|
|
resp_json = json.loads(response.get_data(as_text=True))["data"]
|
|
|
|
|
assert resp_json["event_type"] == data["event_type"]
|
|
|
|
|
assert resp_json["data"]["something"] == data["data"]["something"]
|
|
|
|
|
assert resp_json["data"]["in_fact"] == data["data"]["in_fact"]
|