I need some help with *integration* tests. Hope will get help here.
Hey folks,
I need some help with *integration* tests. Hope will get help here.
I work on `Django`, `DRF` project. We have unittests written using pytest and some pytest plugins. Now it's time to write integration tests for our REST API and the problem is that I can't find any examples in the web. I have some scenarios that should be tested.
Here is an example...
etc...
Assuming that each `>...` is a test case I tried following
Looking for your feedback.
Thanks in advance.
I need some help with *integration* tests. Hope will get help here.
I work on `Django`, `DRF` project. We have unittests written using pytest and some pytest plugins. Now it's time to write integration tests for our REST API and the problem is that I can't find any examples in the web. I have some scenarios that should be tested.
Here is an example...
User creates an account
>User signs in
etc...
Assuming that each `>...` is a test case I tried following
import pytestbut the second test fails because of *db isolation* between tests. The questions is how to test this kind of scenarios ? What is the right way of writing integration tests for REST API ?
import requests
from django.urls import reverse
@pytest.mark.dependency(name='001')
def test_signup(live_server):
payload = dict(
email='[email protected]',
password='password',
)
response = requests.post('http://{host}:{port}{resource}'.format(
host=live_server.thread.host,
port=live_server.thread.port,
resource=reverse('api:signup')), payload)
assert response.status_code == 201
@pytest.mark.dependency(name='002', depends=['001'])
def test_signin(live_server):
payload = dict(
email_or_studio_unique_name='[email protected]',
password='password',
)
response = requests.post('http://{host}:{port}{resource}'.format(
host=live_server.thread.host,
port=live_server.thread.port,
resource=reverse('api:login')), payload)
assert response.status_code == 200
Looking for your feedback.
Thanks in advance.
No any search results
You already invited:
0 Answers