Skip to content

Instantly share code, notes, and snippets.

@mfurquimdev
Created November 25, 2021 18:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mfurquimdev/8e42e5087b6a6ad0d4e0673a01cdb83b to your computer and use it in GitHub Desktop.
Save mfurquimdev/8e42e5087b6a6ad0d4e0673a01cdb83b to your computer and use it in GitHub Desktop.
Using parametrize to pass a list of parameters to a test
@pytest.mark.asyncio
@pytest.mark.parametrize(
"request_body",
[
{
"start_date": "2021-02-01 00:00:00",
"sensors": [],
},
{"start_date": "2021-02-01 00:00:00", "end_date": "2021-02-01 00:30:00"},
],
)
async def test_recalculation_missing_input_parameters(
request_body, async_client, monkeypatch
):
def build_run_workflow_mock(*args, **kwargs):
class TaskMock:
id = "id1"
return TaskMock()
monkeypatch.setattr(
"app.disaggregation.view.build_run_workflow", build_run_workflow_mock
)
log.info(f'request_body = {request_body}')
response = await async_client.post("/recalculation", json=request_body)
assert response.status_code == 422
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment