Browse Source

Hook testing

tags/v0.1^2
Ivan Golikov 2 months ago
parent
commit
9aec8e15a3
3 changed files with 36 additions and 1 deletions
  1. +1
    -1
      keeper/service/views.py
  2. +5
    -0
      tests/conftest.py
  3. +30
    -0
      tests/test_hook.py

+ 1
- 1
keeper/service/views.py View File

@@ -31,4 +31,4 @@ def hook():

status_code = Status.OK if is_valid else Status.SERVER_ERROR

return response, status_code
return response, status_code.value

+ 5
- 0
tests/conftest.py View File

@@ -16,3 +16,8 @@ def app():

os.close(output_fd)
os.unlink(output_path)


@pytest.fixture
def client(app):
return app.test_client()

+ 30
- 0
tests/test_hook.py View File

@@ -0,0 +1,30 @@
from keeper.service.enums import (
HttpStatusCodesEnum as Status,
)


def test_hook(client):
hook_path = '/service/hook'

test_data = [
{
'data': {'id': 1, 'datetime': '2021-07-03T13:00:00.000+03:00', 'type': 'info', 'message': 'Check-check'},
'status_code': Status.OK.value,
'result': 'OK',
'messages': False,
},
{
'data': {},
'status_code': Status.SERVER_ERROR.value,
'result': 'Error',
'messages': True,
}
]

for test in test_data:
post_result = client.post(hook_path, json=test['data'])
post_result_json = post_result.get_json()

assert post_result.status_code == test['status_code']
assert post_result_json.get('result') == test['result']
assert bool(post_result_json.get('messages')) == test['messages']

Loading…
Cancel
Save