-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add tests for petri output and moved petri rendering into request (#246)
- Loading branch information
Showing
2 changed files
with
22 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,27 @@ | ||
from sanic import Sanic | ||
import pytest | ||
from sanic_testing.reusable import ReusableClient | ||
from time import sleep | ||
|
||
@pytest.mark.asyncio | ||
async def test_live(app: Sanic): | ||
request, response = await app.asgi_client.get("/health/liveness") | ||
def test_post(app: Sanic, post_data): | ||
with open('tests/data/rodents.csv') as f: | ||
input_data = f.read() | ||
with ReusableClient(app) as client: | ||
post_data['csvString'] = input_data | ||
request, response_post = client.post('/post', data=post_data) | ||
assert response_post.status == 200 | ||
|
||
assert response.status == 200 | ||
workdir_url = f'/workdir/{post_data['uuid']}/{post_data['spreadsheetId']}/{post_data['sheetId']}' | ||
|
||
@pytest.mark.asyncio | ||
async def test_post(app: Sanic, post_data): | ||
with open('tests/data/rodents.csv') as f: | ||
input_data = f.read() | ||
request, response_json = client.get(f'{workdir_url}/aajson/LATEST.json') | ||
assert response_json.status == 200 | ||
|
||
sleep(1) | ||
|
||
request, response_json = client.get(f'{workdir_url}/petri/LATEST.png') | ||
assert response_json.status == 200 | ||
|
||
post_data['csvString'] = input_data | ||
request, response = await app.asgi_client.post('/post', data=post_data) | ||
request, response_json = client.get(f'{workdir_url}/petri/LATEST.svg') | ||
assert response_json.status == 200 | ||
|
||
assert response.status == 200 | ||
request, response_json = client.get(f'{workdir_url}/petri/LATEST-small.png') | ||
assert response_json.status == 200 |