Beispiel #1
0
    def test_payment_is_configured_on_registration(self, _):
        generate_payment(
            self.event,
            payment_type=1,
            deadline=timezone.now() + timezone.timedelta(days=1),
        )
        attendance = self.event.attendance_event
        attendance.guest_attendance = True
        attendance.save()

        register_response = self.client.post(
            self.get_register_url(self.event.id), self.recaptcha_arg,
            **self.headers)

        self.assertEqual(register_response.status_code,
                         status.HTTP_201_CREATED)
        self.assertFalse(register_response.json().get("has_paid"))

        pay_for_event(self.event, self.user)

        attendee_response = self.client.get(
            self.get_attendee_url(self.event.id), **self.headers)

        self.assertEqual(attendee_response.status_code, status.HTTP_200_OK)
        self.assertTrue(attendee_response.json().get("has_paid"))
Beispiel #2
0
    def test_user_can_view_their_own_payments(self):
        payment_relation = pay_for_event(self.event, self.user)

        response = self.client.get(self.id_url(payment_relation.id),
                                   **self.headers)

        self.assertEqual(response.status_code, status.HTTP_200_OK)
        self.assertEqual(response.json().get("payment").get("id"),
                         self.payment.id)
Beispiel #3
0
    def test_user_cannot_view_other_users_payments(self):
        other_user = generate_user(username="******")
        attend_user_to_event(self.event, other_user)
        payment_relation = pay_for_event(self.event, other_user)

        response = self.client.get(self.id_url(payment_relation.id),
                                   **self.headers)

        self.assertEqual(response.status_code, status.HTTP_404_NOT_FOUND)
        self.assertEqual(response.json().get("detail"), "Ikke funnet.")