Skip to content

Commit

Permalink
Merge branch 'feature/141-tests-for-volunteer' of https://github.com/…
Browse files Browse the repository at this point in the history
…ISPP-G5/NexONG_Backend into feature/141-tests-for-volunteer
  • Loading branch information
mromalde committed Apr 16, 2024
2 parents 66556cb + 45a19e8 commit 8978ef8
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 15 deletions.
17 changes: 12 additions & 5 deletions nexong/api/Authentication/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,20 @@ def setUp(self):
}
add_files_to_volunteer_data(self)
self.volunteer2 = Volunteer.objects.create(
academic_formation="Test formation", motivation="Test motivation", status="PENDIENTE", address="Test address", postal_code= "12345",
birthdate= "1956-07-05",
start_date= "1956-07-05",
end_date= "1956-07-05",
academic_formation="Test formation",
motivation="Test motivation",
status="PENDIENTE",
address="Test address",
postal_code="12345",
birthdate="1956-07-05",
start_date="1956-07-05",
end_date="1956-07-05",
)
self.user2 = User.objects.create(
username="testuser", email="example@gmail.com", role=VOLUNTEER, volunteer= self.volunteer2
username="testuser",
email="example@gmail.com",
role=VOLUNTEER,
volunteer=self.volunteer2,
)
self.token = Token.objects.create(user=self.user2)

Expand Down
15 changes: 10 additions & 5 deletions nexong/api/Event/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -371,14 +371,19 @@ def test_delete_lesson_event_by_admin(self):
)
self.assertEqual(response.status_code, status.HTTP_204_NO_CONTENT)


class VolunteerEventApiViewSetTestCase(TestCase):
def setUp(self):
self.factory = APIRequestFactory()
self.volunteer = Volunteer.objects.create(
academic_formation="Test formation", motivation="Test motivation", status="ACEPTADO", address="Test address", postal_code= "12345",
birthdate= "1956-07-05",
start_date= "1956-07-05",
end_date= "1956-07-05",
academic_formation="Test formation",
motivation="Test motivation",
status="ACEPTADO",
address="Test address",
postal_code="12345",
birthdate="1956-07-05",
start_date="1956-07-05",
end_date="1956-07-05",
)
self.family2 = Family.objects.create(name="Familia Pedriza")
self.education_center2 = EducationCenter.objects.create(
Expand Down Expand Up @@ -581,4 +586,4 @@ def test_update_lesson_event_by_volunteer(self):
content_type="application/json",
HTTP_AUTHORIZATION=f"Token {self.token.key}",
)
self.assertEqual(response.status_code, status.HTTP_401_UNAUTHORIZED)
self.assertEqual(response.status_code, status.HTTP_401_UNAUTHORIZED)
12 changes: 8 additions & 4 deletions nexong/api/Lesson/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@ def test_delete_lesson_attendance_by_admin(self):
)
self.assertEqual(response.status_code, 204)


class VolunteerLessonApiViewSetTestCase(TestCase):
def setUp(self):
self.factory = APIRequestFactory()
Expand All @@ -222,7 +223,10 @@ def setUp(self):
end_date="1980-07-05",
)
self.user2 = User.objects.create(
username="testuser", email="example@gmail.com", role=VOLUNTEER, volunteer=self.volunteer3
username="testuser",
email="example@gmail.com",
role=VOLUNTEER,
volunteer=self.volunteer3,
)
self.family2 = Family.objects.create(name="Familia Pedraza")
self.education_center2 = EducationCenter.objects.create(
Expand Down Expand Up @@ -301,7 +305,7 @@ def test_create_lesson_attendance_by_volunteer(self):
data={
"date": "2025-04-21",
"lesson": f"{self.lesson2.id}",
"volunteer": f"{self.volunteer2.id}"
"volunteer": f"{self.volunteer2.id}",
},
HTTP_AUTHORIZATION=f"Token {self.token.key}",
)
Expand All @@ -313,9 +317,9 @@ def test_update_lesson_attendance_by_volunteer(self):
data={
"date": "2025-04-21",
"lesson": f"{self.lesson2.id}",
"volunteer": f"{self.volunteer3.id}"
"volunteer": f"{self.volunteer3.id}",
},
content_type="application/json",
HTTP_AUTHORIZATION=f"Token {self.token.key}",
)
self.assertEqual(response.status_code, status.HTTP_200_OK)
self.assertEqual(response.status_code, status.HTTP_200_OK)
2 changes: 1 addition & 1 deletion nexong/api/Lesson/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class LessonAttendanceApiViewSet(ModelViewSet):
queryset = LessonAttendance.objects.all()
http_method_names = ["get", "post", "put", "delete"]
serializer_class = LessonAttendanceSerializer
#permission_classes = [isEducatorGet | isVolunteerPostPutAndGet | isAdmin]
# permission_classes = [isEducatorGet | isVolunteerPostPutAndGet | isAdmin]

def destroy(self, request, *args, **kwargs):
instance = self.get_object()
Expand Down

0 comments on commit 8978ef8

Please sign in to comment.