mirror of
https://github.com/TandoorRecipes/recipes.git
synced 2026-01-02 04:39:54 -05:00
basics of pytest
This commit is contained in:
20
cookbook/tests/pytest/test_test.py
Normal file
20
cookbook/tests/pytest/test_test.py
Normal file
@@ -0,0 +1,20 @@
|
||||
import json
|
||||
|
||||
import pytest
|
||||
|
||||
from django.contrib.auth.models import User
|
||||
from django.urls import reverse
|
||||
from django_scopes import scopes_disabled
|
||||
|
||||
from cookbook.models import Keyword, Space
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
def test_user_create(user_1, user_2):
|
||||
r = user_1.post(reverse('api:keyword-list'), {'name': 'test', 'space': 1}, content_type='application/json')
|
||||
response = json.loads(r.content)
|
||||
assert r.status_code == 201
|
||||
assert response['name'] == 'test'
|
||||
|
||||
r = user_2.get(reverse('api:keyword-detail', args={response['id']}), content_type='application/json')
|
||||
assert r.status_code == 404
|
||||
Reference in New Issue
Block a user