Beispiel #1
0
    def test_anonymous_create(self):
        emp, customer, service = emp_customer_service()
        data = create_apt_data(
            emp, customer, service,
            util.next_wednesday().replace(hour=10, minute=0))

        response = self.client.post(self.list_url, data, format='json')

        self.assertEqual(response.status_code, status.HTTP_401_UNAUTHORIZED)
Beispiel #2
0
 def test_get_inside_locked_period(self):
     """
     When an employee has a locked period that ranges for days, no slots should be retrieved for the full range.
     """
     lock = util.book_appointment(
         self.emp,
         start=util.next_tuesday().replace(hour=9, minute=15),
         end=util.next_tuesday(7).replace(hour=9, minute=15))
     slots = self.get_slots_for_emp(util.next_wednesday())
     self.assertEqual(len(slots), 0)
Beispiel #3
0
    def test_intent_created(self):
        request = Request.objects.get_current(1, 3)
        user = User.objects.get(pk=3)
        request.add_appointment(user, service_id=1, employee_id=1, owner_id=1,
                                start=test_util.next_wednesday().replace(hour=9, minute=00))

        self.client.force_authenticate(user)
        detail_url = reverse('payment-detail', kwargs={'pk': request.id})
        intent_result = self.client.put(detail_url)

        self.assertEqual(intent_result.status_code, status.HTTP_200_OK)
Beispiel #4
0
    def test_employee_create_for_other_employee(self):
        emp, customer, service = emp_customer_service()
        data = create_apt_data(
            emp, customer, service,
            util.next_wednesday().replace(hour=10, minute=0))

        emp2 = models.Employee.objects.get(pk=2)
        emp2.user = test_user(emp2)
        self.client.force_authenticate(user=emp2.user)
        response = self.client.post(self.list_url, data, format='json')

        self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN)
Beispiel #5
0
    def test_payment_intent_success(self):
        request = Request.objects.get_current(1, 3)
        user = User.objects.get(pk=3)
        request.add_appointment(user, service_id=1, employee_id=1, owner_id=1,
                                start=test_util.next_wednesday().replace(hour=9, minute=00))
        event = get_intent_succeeded_event()
        intent, created = models.PaymentIntent.objects.get_or_create(request.id)
        intent.stripe_id = event.data.object.id
        intent.save()

        handler_result = AccountHookHandler(event).handle()
        intent = models.PaymentIntent.objects.get(pk=intent.id)

        self.assertTrue(intent.paid)
        self.assertTrue(intent.amount_received, 2000)
        self.assertTrue(handler_result)
Beispiel #6
0
    def setUp(self):
        self.list_url = reverse('appointment-list')
        self.detail = 'appointment-detail'
        self.model = models.Appointment

        kwargs = {}

        for emp in models.Employee.objects.all():
            kwargs['service'] = emp.services.first()
            kwargs['start'] = util.next_wednesday().replace(hour=9, minute=00)
            kwargs['employee'] = emp
            kwargs['owner'] = emp.owner
            for customer in models.Customer.objects.all():
                if customer.owner_id == emp.owner_id:
                    kwargs['customer'] = customer
                    kwargs['status'] = 'A'
                    models.Appointment.objects.create(**kwargs)
                    kwargs[
                        'start'] = kwargs['start'] + kwargs['service'].duration
Beispiel #7
0
    def test_create_appointment_new_company(self):
        """
        Adding an appointment to a request should require employee, service and start date.
        In the case where the user is not linked to a customer in the company,
            a new additional customer model should be created for the company the appointment is being created
        """

        emp, service = emp_service(Company.objects.get(pk=2))
        user = User.objects.get(pk=2)
        data = create_apt_data(emp, service, util.next_wednesday().replace(hour=10, minute=0))

        before_count = user.customer_set.all().count()

        self.client.force_authenticate(user=user)
        response = self.client.post(self.list_url + 'add/', data, format='json')

        after_count = user.customer_set.all().count()

        self.assert_user_customers_same_params(user)
        self.assert_response_contains_customer_with_user_data(user, response)
        self.assertEqual(response.status_code, status.HTTP_201_CREATED)
        self.assertEqual(before_count + 1, after_count)