tests/gateway/post_upload: Use webtest.TestApp for functional tests

This commit is contained in:
Athanasius 2022-08-19 15:07:24 +01:00
parent 30282ba95e
commit 6b339e3b11
No known key found for this signature in database
GPG Key ID: 8C392035DD80FD62

View File

@ -0,0 +1,30 @@
"""Tests via `bottle` endpoints."""
import os
import sys
from typing import Callable
from webtest import TestApp
# Tests don't include the directory that `pytest` is run from on sys.path
sys.path.append(os.getcwd())
import eddn.Gateway # noqa: E402 # Has to be after that sys.path fixup
def test_plain_message(eddn_message: Callable) -> None:
"""Test eddn.Gateway /upload/ with a plain message."""
eddn.Gateway.setup_bottle_app()
# Wrap the real app in a TestApp object
test_app = TestApp(eddn.Gateway.app)
assert test_app is not None
dc_msg = test_app.post(
'/upload/',
params=eddn_message('plain_journal_scan_valid'),
headers={
'Content-Type': 'application/json'
},
)
assert dc_msg == 'OK'