From f2da12e676f8beaeae35d0c0735ea6ce2dd2d1c7 Mon Sep 17 00:00:00 2001 From: Antony Nyagah Date: Sat, 30 Mar 2024 12:34:31 +0300 Subject: [PATCH] add working tests for the login view --- backend/tests/test_views_login.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 backend/tests/test_views_login.py diff --git a/backend/tests/test_views_login.py b/backend/tests/test_views_login.py new file mode 100644 index 00000000..6ec6bf84 --- /dev/null +++ b/backend/tests/test_views_login.py @@ -0,0 +1,20 @@ +from django.test import TestCase +from rest_framework.test import APIClient + +client = APIClient() + +API_BASE = "http://testserver/api/v1" + + +class LoginViewTestCase(TestCase): + def test_login_url_returns_200(self): + response = client.get(f"{API_BASE}/auth/login/") + self.assertEqual(response.status_code, 200) + + def test_response_type_is_json(self): + response = client.get(f"{API_BASE}/auth/login/") + self.assertEqual(response["content-type"], "application/json") + + def test_response_contains_login_url(self): + response = client.get(f"{API_BASE}/auth/login/") + self.assertTrue("login_url" in response.json())