Skip to content

Commit

Permalink
Addd ContactViewUser unittest
Browse files Browse the repository at this point in the history
  • Loading branch information
DEENUU1 committed Dec 9, 2023
1 parent 36afd56 commit 013fa4f
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 3 deletions.
5 changes: 2 additions & 3 deletions tests/test_payment/test_views.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import pytest
from rest_framework.test import force_authenticate, APIRequestFactory
from rest_framework.test import APIRequestFactory
from payment.views import SuccessView, CancelView

factory = APIRequestFactory()
Expand All @@ -12,9 +12,8 @@ def test_success_return_success_view():
assert response.status_code == 200



@pytest.mark.django_db
def test_success_return_cancel_view():
request = factory.get("/payment/cancel")
response = CancelView.as_view()(request)
assert response.status_code == 200
assert response.status_code == 200
26 changes: 26 additions & 0 deletions tests/test_support/test_views.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import pytest
from tests.fixtures import user, job_offer, job_offer_with_company, user_second, company
from rest_framework.test import force_authenticate, APIRequestFactory
from support.views import ContactViewUser, ReportCreateView
import json
from support.models import Contact, Report

factory = APIRequestFactory()


@pytest.mark.django_db
def test_success_create_contact_object():
request = factory.post(
'/api/support/',
json.dumps({
"subject": "test message",
"message": "test message",
"email": "[email protected]",
}),
content_type='application/json'
)
view = ContactViewUser.as_view({"post": "create"})
response = view(request)

assert response.status_code == 201
assert Contact.objects.count() == 1

0 comments on commit 013fa4f

Please sign in to comment.