Http(s) Requests Testing
Module to test https request calls using the request package.
Targets are mostly mocked using pytest-mock plugin:
poetry add --dev pytest-mock
Meant to serve as template in case the package uses url based api calls.
- tests.test_http_requests.request_rnd_wiki_artcl()[source]
Try reaching the wikipedia site to get a random article.
- tests.test_http_requests.test_mock_gets_called(mock_requests_get, request_rnd_wiki_artcl)[source]
Assert the requests.get was actually called.
random_wiki_article gets called by fixutre wrap around mock object so the mock object is “requests.get” instead of the url. Fixture order is important!
Since the data content is not of importance calling the fixture alone suffices.
- tests.test_http_requests.test_mock_result_inspection(mock_requests_get, request_rnd_wiki_artcl)[source]
Test successful mock result inspection.
- tests.test_http_requests.test_mock_param_call_inspection(mock_requests_get, request_rnd_wiki_artcl)[source]
Assert the requests.get was called properly.
Random_wiki_article gets called by fixutre wrap around mock object so the mock object is “requests.get” instead of the url. Fixture order is implortant! Since the data content is not of importance calling the fixture alone suffices.