Coverage for articles/tests/test_forms.py: 100.00%

20 statements  

« prev     ^ index     » next       coverage.py v7.16.2, created at 2026-10-13 20:21 -0700

1import pytest 1a

2from django.urls import reverse 1a

3 

4from ..views import ( 1a

5 article_create, 

6 article_update, 

7) 

8 

9 

10@pytest.mark.django_db 1a

11def test_article_form_valid_on_create_view(rf, admin_user): 1a

12 form_data = { 1a

13 "title": "A new late night test", 

14 "body": "This is the body of the form test.", 

15 "tags": "test, django, article, news", 

16 } 

17 

18 request = rf.post(reverse("article_new"), form_data) 1a

19 request.user = admin_user 1a

20 

21 response = article_create(request) 1a

22 assert response.status_code == 200 1a

23 assert True 1a

24 

25 

26@pytest.mark.django_db 1a

27def test_article_form_valid_on_update_view(rf, article, admin_user): 1a

28 form_data = { 1a

29 "title": "A new late night test", 

30 "body": "This is the body of the form test.", 

31 "tags": "newtag", 

32 } 

33 

34 url = reverse("article_update", kwargs={"pk": article.id}) 1a

35 # Make a request for our new message 

36 request = rf.post(url, form_data) 1a

37 request.user = admin_user 1a

38 

39 response = article_update(request, pk=article.id) 1a

40 assert response.status_code == 200 1a

41 assert True 1a