Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 12 additions & 18 deletions tests/test_modules_same_name_body/test_main.py
Original file line number Diff line number Diff line change
@@ -1,33 +1,27 @@
import pytest
from fastapi.testclient import TestClient

from .app.main import app

client = TestClient(app)


def test_post_a():
@pytest.mark.parametrize(
"path", ["/a/compute", "/a/compute/", "/b/compute", "/b/compute/"]
)
def test_post(path):
data = {"a": 2, "b": "foo"}
response = client.post("/a/compute", json=data)
response = client.post(path, json=data)
assert response.status_code == 200, response.text
data = response.json()
assert data == response.json()


def test_post_a_invalid():
@pytest.mark.parametrize(
"path", ["/a/compute", "/a/compute/", "/b/compute", "/b/compute/"]
)
def test_post_invalid(path):
data = {"a": "bar", "b": "foo"}
response = client.post("/a/compute", json=data)
assert response.status_code == 422, response.text


def test_post_b():
data = {"a": 2, "b": "foo"}
response = client.post("/b/compute/", json=data)
assert response.status_code == 200, response.text
data = response.json()


def test_post_b_invalid():
data = {"a": "bar", "b": "foo"}
response = client.post("/b/compute/", json=data)
response = client.post(path, json=data)
assert response.status_code == 422, response.text


Expand Down