Skip to content

Commit

Permalink
remove testing of deleted view
Browse files Browse the repository at this point in the history
  • Loading branch information
tekanokhambane committed May 1, 2024
1 parent a3c1406 commit 81a3240
Showing 1 changed file with 47 additions and 47 deletions.
94 changes: 47 additions & 47 deletions multitenancy/users/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from rest_framework.test import APITestCase, APIRequestFactory, APIClient
from multitenancy.users.views import (
CreateCustomerView,
CreateStaffView,
# CreateStaffView,
DeleteCustomerView,
CustomerListView,
DeleteStaffView,
Expand Down Expand Up @@ -305,52 +305,52 @@ def setUp(self):
}
self.staff_obj = Staff.objects.first()

def test_get_create_staff_view(self):
# self.user = Admin.objects.create(
# username="admin",
# password="password",
# first_name="abc123",
# last_name="pooemd",
# email="[email protected]",
# type="Admin",
# is_active=True,
# )

self.user = Admin.objects.get(email="[email protected]")
self.client.force_login(user=self.user)
request = self.factory.get("/admin/staff/create/")
request.user = self.user
response = CreateStaffView.as_view()(request)
self.assertEqual(response.status_code, 200)
self.assertTrue(self.client.session.get("_auth_user_id"))
self.assertIn("_auth_user_id", self.client.session)

def test_post_create_staff_view(self):
self.user = Admin.objects.get(email="[email protected]")
self.client.force_login(user=self.user)
request = self.factory.post("/admin/staff/create/", data=self.staff_data)
request.user = self.user
response = CreateStaffView.as_view()(request)
self.assertEqual(response.status_code, 200)

def test_get_create_staff_view_unauthenticated(self):
try:
self.user = TenantUser.objects.get(
email="AnonymousUser",
)
assert self.user is not None

self.client.force_login(user=self.user)
request = self.factory.get("/admin/staff/create/")
assert request is not None
request.user = self.user
assert request.user is not None

response = CreateStaffView.as_view()(request)
assert response is not None
self.assertEqual(response.status_code, 403)
except Exception as e:
print(f"Exception raised: {str(e)}")
# def test_get_create_staff_view(self):
# # self.user = Admin.objects.create(
# # username="admin",
# # password="password",
# # first_name="abc123",
# # last_name="pooemd",
# # email="[email protected]",
# # type="Admin",
# # is_active=True,
# # )

# self.user = Admin.objects.get(email="[email protected]")
# self.client.force_login(user=self.user)
# request = self.factory.get("/admin/staff/create/")
# request.user = self.user
# response = CreateStaffView.as_view()(request)
# self.assertEqual(response.status_code, 200)
# self.assertTrue(self.client.session.get("_auth_user_id"))
# self.assertIn("_auth_user_id", self.client.session)

# def test_post_create_staff_view(self):
# self.user = Admin.objects.get(email="[email protected]")
# self.client.force_login(user=self.user)
# request = self.factory.post("/admin/staff/create/", data=self.staff_data)
# request.user = self.user
# response = CreateStaffView.as_view()(request)
# self.assertEqual(response.status_code, 200)

# def test_get_create_staff_view_unauthenticated(self):
# try:
# self.user = TenantUser.objects.get(
# email="AnonymousUser",
# )
# assert self.user is not None

# self.client.force_login(user=self.user)
# request = self.factory.get("/admin/staff/create/")
# assert request is not None
# request.user = self.user
# assert request.user is not None

# response = CreateStaffView.as_view()(request)
# assert response is not None
# self.assertEqual(response.status_code, 403)
# except Exception as e:
# print(f"Exception raised: {str(e)}")

def test_update_staff_view(self):
self.user = Admin.objects.get(email="[email protected]")
Expand Down

0 comments on commit 81a3240

Please sign in to comment.