Example #1
0
    def test_user_can_delete_future_paid_reservations(self):
        self.client.login(username=self.user.email, password='******')
        reservation = ReservationFactory(paid=True, user=self.user)
        response = self.client.post(ReservationFactory.get_remove_url(), {'id': reservation.id},
                                    HTTP_X_REQUESTED_WITH="XMLHttpRequest")

        self.assertEqual(response.status_code, http_client.OK)
        self.assertFalse(Reservation.objects.filter(id=reservation.id).exists())
        self.assertEqual(User.objects.get(id=self.user.id).budget, reservation.price)
Example #2
0
 def setUp(self):
     self.user = UserFactory(is_active=True)
     self.field = FieldFactory()
     self.login_data = {'username': self.user.email, 'password': '******'}
     self.reservation_url = ReservationFactory.get_reservation_url()
     self.remove_url = ReservationFactory.get_remove_url()
     self.remove_all_url = ReservationFactory.get_remove_all_url()
     self.payment_url = ReservationFactory.get_reservation_list_url()
     self.all_reservations_url = ReservationFactory.get_all_reservations_url()
     self.reservation_list_url = ReservationFactory.get_reservation_list_url()
Example #3
0
 def test_user_cannot_delete_paid_reservations_in_past(self):
     self.client.login(username=self.user.email, password='******')
     reservation = ReservationFactory(start=timezone.now() - timedelta(hours=1, minutes=15),
                                      end=timezone.now() - timedelta(minutes=15),
                                      user=self.user, paid=True)
     response = self.client.post(ReservationFactory.get_remove_url(), {'id': reservation.id},
                                 HTTP_X_REQUESTED_WITH="XMLHttpRequest")
     self.assertEqual(response.status_code, http_client.BAD_REQUEST)
     self.assertEqual(response.content.decode('utf-8'), "Cannot delete the reservation.")
     self.assertTrue(Reservation.objects.filter(id=reservation.id).exists())
     self.assertNotEqual(User.objects.get(id=self.user.id).budget, reservation.price)
Example #4
0
    def test_user_can_delete_future_paid_reservations(self):
        self.client.login(username=self.user.email, password='******')
        reservation = ReservationFactory(paid=True, user=self.user)
        response = self.client.post(ReservationFactory.get_remove_url(),
                                    {'id': reservation.id},
                                    HTTP_X_REQUESTED_WITH="XMLHttpRequest")

        self.assertEqual(response.status_code, http_client.OK)
        self.assertFalse(
            Reservation.objects.filter(id=reservation.id).exists())
        self.assertEqual(
            User.objects.get(id=self.user.id).budget, reservation.price)
Example #5
0
 def setUp(self):
     self.user = UserFactory(is_active=True)
     self.field = FieldFactory()
     self.login_data = {
         'username': self.user.email,
         'password': '******'
     }
     self.reservation_url = ReservationFactory.get_reservation_url()
     self.remove_url = ReservationFactory.get_remove_url()
     self.remove_all_url = ReservationFactory.get_remove_all_url()
     self.payment_url = ReservationFactory.get_reservation_list_url()
     self.all_reservations_url = ReservationFactory.get_all_reservations_url(
     )
     self.reservation_list_url = ReservationFactory.get_reservation_list_url(
     )
Example #6
0
 def test_user_cannot_delete_paid_reservations_in_past(self):
     self.client.login(username=self.user.email, password='******')
     reservation = ReservationFactory(
         start=timezone.now() - timedelta(hours=1, minutes=15),
         end=timezone.now() - timedelta(minutes=15),
         user=self.user,
         paid=True)
     response = self.client.post(ReservationFactory.get_remove_url(),
                                 {'id': reservation.id},
                                 HTTP_X_REQUESTED_WITH="XMLHttpRequest")
     self.assertEqual(response.status_code, http_client.BAD_REQUEST)
     self.assertEqual(response.content.decode('utf-8'),
                      "Cannot delete the reservation.")
     self.assertTrue(Reservation.objects.filter(id=reservation.id).exists())
     self.assertNotEqual(
         User.objects.get(id=self.user.id).budget, reservation.price)