Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add missing test case #607

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions app/tests/base.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from datetime import datetime, timedelta

from django.test import TestCase

from app import factories, models
Expand Down Expand Up @@ -37,6 +39,7 @@ def setUp(self) -> None:
is_default=True,
organization=self.organization,
)

self.owner = factories.UserFactory(
username="[email protected]",
email="[email protected]",
Expand Down Expand Up @@ -167,3 +170,9 @@ def setUp(self) -> None:

self.folder = factories.FolderFactory()
self.document = factories.DocumentFactory()
self.leave = factories.LeaveFactory(
employee=self.employee,
organization=self.organization,
leave_from=datetime.now(),
leave_to=datetime.now() + +timedelta(days=1),
)
16 changes: 16 additions & 0 deletions app/tests/test_employee.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,12 @@ def test_employee_list_neagtive(self):

self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN)

def test_employee_delete(self):
self.client.force_login(self.owner)
response = self.client.delete(f"/api/employees/{self.employee.id}/")

self.assertEqual(response.status_code, status.HTTP_204_NO_CONTENT)


class CompensationTestCase(BaseTestCase):
def test_compensation_post(self):
Expand Down Expand Up @@ -881,6 +887,16 @@ def test_get_all_leaves(self):
response = self.client.get("/api/attendance/?id=2")
self.assertEqual(response.status_code, status.HTTP_200_OK)

def test_leave_update(self):
self.client.force_login(self.owner)
data = {
"updated_by": self.owner.id,
"hr_comment": "leave approved.",
"status": "approved",
}
response = self.client.patch(f"/api/leave/{self.leave.id}/", data=data)
self.assertEqual(response.status_code, status.HTTP_200_OK)


class StandupTestCase(BaseTestCase):
def test_standup_get(self):
Expand Down
13 changes: 13 additions & 0 deletions app/tests/folder.py → app/tests/test_folder.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,3 +104,16 @@ def test_document_delete(self):
self.client.force_login(self.owner)
response = self.client.delete(f"/api/documents/{self.document.id}/")
self.assertEqual(response.status_code, 204)


class AWSTestCase(BaseTestCase):
def test_aws_upload_file(self):
self.client.force_login(self.owner)
data = {"filename": "test", "filetype": ".jpg"}
response = self.client.post("/api/aws_upload_file/", data=data)
self.assertEqual(response.status_code, status.HTTP_200_OK)

def test_aws_delete_upload_file(self):
self.client.force_login(self.owner)
response = self.client.delete("/api/aws_delete_file/key/")
self.assertEqual(response.status_code, status.HTTP_204_NO_CONTENT)
32 changes: 32 additions & 0 deletions app/tests/test_user.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,36 @@ def test_user_change_password_negative(self):
response = self.client.patch("/api/change_password/", data=user_data)
self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)

def test_user_reset_password(self):
data = {"email": "[email protected]"}
response = self.client.post("/api/password-reset/", data=data)
self.assertEqual(response.status_code, status.HTTP_200_OK)

def test_user_reset_password_negative(self):
data = {"email": "[email protected]"}
response = self.client.post("/api/password-reset/", data=data)
self.assertEqual(response.status_code, status.HTTP_404_NOT_FOUND)

def test_login(self):
login_data = {"email": "[email protected]", "password": "admin"}
response = self.client.post("/api/login/", data=login_data)
self.assertEqual(response.status_code, status.HTTP_200_OK)

def test_login_invalid_credential(self):
login_data = {"email": "[email protected]", "password": "admin1"}
response = self.client.post("/api/login/", data=login_data)
self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)

def test_delete_user(self):
self.client.force_login(self.owner)
response = self.client.delete(f"/api/users/{self.org_user.id}/")
self.assertEqual(response.status_code, status.HTTP_204_NO_CONTENT)

def test_delete_user_negative(self):
self.client.force_login(self.owner)
response = self.client.delete(f"/api/users/{self.owner.id}/")
self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)

def test_onboarding(self):
onboarding_data = {
"first_name": "Test",
Expand All @@ -49,3 +74,10 @@ def test_get_user_filter_data(self):
self.client.force_login(self.owner)
response = self.client.get("/api/users/")
self.assertEqual(response.status_code, status.HTTP_200_OK)


class UserModuleRoleTestCase(BaseTestCase):
def test_get_user_list(self):
self.client.force_login(self.owner)
response = self.client.get(f"/api/users/{self.owner.id}/access/")
self.assertEqual(response.status_code, status.HTTP_200_OK)