Skip to content

Commit

Permalink
Added tests for donation app
Browse files Browse the repository at this point in the history
  • Loading branch information
EXG1O committed Jan 23, 2024
1 parent 0edc192 commit 42b5f38
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 3 deletions.
31 changes: 31 additions & 0 deletions donation/tests.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
from django.test import TestCase
from django.http import HttpResponse
from django.urls import reverse

from rest_framework.test import APIClient


class CustomTestCase(TestCase):
def setUp(self) -> None:
self.client: APIClient = APIClient()

class DonationsAPIViewTests(CustomTestCase):
url: str = reverse('api:donation:index')

def test_get_method(self) -> None:
response: HttpResponse = self.client.get(self.url)
self.assertEqual(response.status_code, 200)

class DonationSectionsAPIViewTests(CustomTestCase):
url: str = reverse('api:donation:sections')

def test_get_method(self) -> None:
response: HttpResponse = self.client.get(self.url)
self.assertEqual(response.status_code, 200)

class DonationButtonsAPIViewTests(CustomTestCase):
url: str = reverse('api:donation:buttons')

def test_get_method(self) -> None:
response: HttpResponse = self.client.get(self.url)
self.assertEqual(response.status_code, 200)
7 changes: 4 additions & 3 deletions donation/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@
)


app_name = 'donation'
urlpatterns = [
path('', DonationsAPIView.as_view()),
path('sections/', DonationSectionsAPIView.as_view()),
path('buttons/', DonationButtonsAPIView.as_view()),
path('', DonationsAPIView.as_view(), name='index'),
path('sections/', DonationSectionsAPIView.as_view(), name='sections'),
path('buttons/', DonationButtonsAPIView.as_view(), name='buttons'),
]

0 comments on commit 42b5f38

Please sign in to comment.