示例#1
0
    def test_paypal_email_and_check_must_match(self):
        form = EventAdminForm(
            data=self.form_data(
                {
                    'paypal_email': '*****@*****.**',
                    'paypal_email_check': '*****@*****.**'
                },
            ),
            ev_type='CL'
        )
        self.assertFalse(form.is_valid())
        self.assertIn(
            'Email addresses do not match',
            str(form.errors['paypal_email_check'])
        )
        self.assertIn(
            'Email addresses do not match',
            str(form.errors['paypal_email'])
        )

        form = EventAdminForm(
            data=self.form_data(
                {
                    'paypal_email': '*****@*****.**',
                    'paypal_email_check': '*****@*****.**'
                },
            ),
            ev_type='CL'
        )
        self.assertTrue(form.is_valid())
示例#2
0
 def test_invalid_payment_due_date(self):
     form = EventAdminForm(data=self.form_data(
         {'payment_due_date': '31 Jun 2015'}),
                           ev_type='CL')
     self.assertFalse(form.is_valid())
     self.assertIn('Invalid date format',
                   str(form.errors['payment_due_date']))
示例#3
0
 def test_paypal_email_check_required_if_paypal_email_changed(self):
     form = EventAdminForm(data=self.form_data(
         {'paypal_email': '*****@*****.**'}),
                           ev_type='CL')
     self.assertFalse(form.is_valid())
     self.assertIn('Please reenter paypal email to confirm changes',
                   str(form.errors['paypal_email_check']))
示例#4
0
 def test_form_with_invalid_contact_person(self):
     form = EventAdminForm(
         data=self.form_data({'contact_person': ''}), ev_type='CL')
     self.assertFalse(form.is_valid())
     self.assertEquals(len(form.errors), 1)
     self.assertIn('contact_person', form.errors.keys())
     self.assertIn(['This field is required.'], form.errors.values())
示例#5
0
 def test_form_with_invalid_contact_person(self):
     form = EventAdminForm(data=self.form_data({'contact_person': ''}),
                           ev_type='CL')
     self.assertFalse(form.is_valid())
     self.assertEquals(len(form.errors), 1)
     self.assertIn('contact_person', form.errors.keys())
     self.assertIn(['This field is required.'], form.errors.values())
示例#6
0
 def test_valid_payment_due_date(self):
     form = EventAdminForm(
         data=self.form_data(
             {'date': '15 Jun 2015 20:00',
              'payment_due_date': '10 Jun 2015'},
         ), ev_type='CL')
     self.assertTrue(form.is_valid())
示例#7
0
 def test_disallow_booking_cancellation_requires_cost(self):
     form = EventAdminForm(data=self.form_data(
         {'allow_booking_cancellation': False}),
                           ev_type='CL')
     self.assertFalse(form.is_valid())
     self.assertIn(
         'Booking cancellation should be allowed for events/classes with '
         'no associated cost',
         str(form.errors['allow_booking_cancellation']))
示例#8
0
 def test_payment_due_date_after_cancellation_period(self):
     form = EventAdminForm(
         data=self.form_data(
             {'date': '15 Jun 2015 20:00',
              'payment_due_date': '16 Jun 2015'},
         ), ev_type='CL')
     self.assertFalse(form.is_valid())
     self.assertIn('Payment due date must be before cancellation period '
                   'starts', str(form.errors['payment_due_date']))
示例#9
0
 def test_valid_payment_due_date(self):
     form = EventAdminForm(data=self.form_data(
         {
             'advance_payment_required': True,
             'date': '15 Jun 2015 20:00',
             'payment_due_date': '10 Jun 2015',
             'cost': 1
         }, ),
                           ev_type='CL')
     self.assertTrue(form.is_valid())
示例#10
0
    def test_name_placeholder(self):
        form = EventAdminForm(data=self.form_data(), ev_type='EV')
        name_field = form.fields['name']
        self.assertEquals(name_field.widget.attrs['placeholder'],
                          'Name of event e.g. Workshop')

        form = EventAdminForm(data=self.form_data(), ev_type='CL')
        name_field = form.fields['name']
        self.assertEquals(name_field.widget.attrs['placeholder'],
                          'Name of class e.g. Pole Level 1')
示例#11
0
 def test_paypal_email_check_required_if_paypal_email_changed(self):
     form = EventAdminForm(
         data=self.form_data(
             {'paypal_email': '*****@*****.**'}),
         ev_type='CL'
     )
     self.assertFalse(form.is_valid())
     self.assertIn(
         'Please reenter paypal email to confirm changes',
         str(form.errors['paypal_email_check'])
     )
示例#12
0
 def test_payment_due_date_after_cancellation_period(self):
     form = EventAdminForm(data=self.form_data(
         {
             'date': '15 Jun 2015 20:00',
             'payment_due_date': '16 Jun 2015'
         }, ),
                           ev_type='CL')
     self.assertFalse(form.is_valid())
     self.assertIn(
         'Payment due date must be before cancellation period '
         'starts', str(form.errors['payment_due_date']))
示例#13
0
 def test_valid_payment_due_date(self):
     form = EventAdminForm(
         data=self.form_data(
             {
              'advance_payment_required': True,
              'date': '15 Jun 2015 20:00',
              'payment_due_date': '10 Jun 2015',
              'cost': 1
             },
         ), ev_type='CL')
     self.assertTrue(form.is_valid())
示例#14
0
 def test_disallow_booking_cancellation_requires_adv_payment_required(self):
     form = EventAdminForm(
         data=self.form_data(
             {'allow_booking_cancellation': False, 'cost': 1}),
         ev_type='CL'
     )
     self.assertFalse(form.is_valid())
     self.assertIn(
         'Advance payment must be required in order to make booking '
         'cancellation disallowed (i.e. non-refundable)',
         str(form.errors['allow_booking_cancellation'])
     )
示例#15
0
 def test_payment_time_allowed_requires_advance_payment_req(self):
     form = EventAdminForm(data=self.form_data(
         {
             'advance_payment_required': False,
             'payment_time_allowed': 4,
             'cost': 1,
         }, ),
                           ev_type='CL')
     self.assertFalse(form.is_valid())
     self.assertIn(
         'To specify payment time allowed, please also tick '
         '"advance payment required"',
         str(form.errors['payment_time_allowed']))
示例#16
0
 def test_disallow_booking_cancellation_requires_adv_payment_required(self):
     form = EventAdminForm(data=self.form_data({
         'allow_booking_cancellation':
         False,
         'cost':
         1
     }),
                           ev_type='CL')
     self.assertFalse(form.is_valid())
     self.assertIn(
         'Advance payment must be required in order to make booking '
         'cancellation disallowed (i.e. non-refundable)',
         str(form.errors['allow_booking_cancellation']))
示例#17
0
 def test_disallow_booking_cancellation_requires_cost(self):
     form = EventAdminForm(
         data=self.form_data(
             {'allow_booking_cancellation': False}
         ),
         ev_type='CL'
     )
     self.assertFalse(form.is_valid())
     self.assertIn(
         'Booking cancellation should be allowed for events/classes with '
         'no associated cost',
         str(form.errors['allow_booking_cancellation'])
     )
示例#18
0
    def test_payment_due_date_requires_advance_payment_req(self):
        form = EventAdminForm(data=self.form_data(
            {
                'advance_payment_required': False,
                'payment_due_date': '01 Jun 2015',
                'cost': 1,
            }, ),
                              ev_type='CL')
        self.assertFalse(form.is_valid())

        self.assertIn(
            'To specify a payment due date, please also tick '
            '"advance payment required&quot',
            str(form.errors['payment_due_date']))
示例#19
0
    def test_event_type_queryset(self):
        form = EventAdminForm(data=self.form_data(), ev_type='EV')
        ev_type_field = form.fields['event_type']
        self.assertEqual(
            set(EventType.objects.filter(id=self.event_type_ev.id)),
            set(ev_type_field.queryset))
        self.assertEquals(len(ev_type_field.queryset), 1)

        form = EventAdminForm(data=self.form_data(), ev_type='CL')
        ev_type_field = form.fields['event_type']
        self.assertEqual(
            set(
                EventType.objects.filter(
                    id__in=[self.event_type.id, self.event_type_oc.id])),
            set(ev_type_field.queryset))
        self.assertEquals(len(ev_type_field.queryset), 2)
示例#20
0
 def test_payment_time_allowed_requires_advance_payment_req(self):
     form = EventAdminForm(
         data=self.form_data(
             {
                 'advance_payment_required': False,
                 'payment_time_allowed': 4,
                 'cost': 1,
             },
         ),
         ev_type='CL'
     )
     self.assertFalse(form.is_valid())
     self.assertIn(
         'To specify payment time allowed, please also tick '
         '"advance payment required"',
         str(form.errors['payment_time_allowed'])
     )
示例#21
0
    def test_event_type_queryset_shows_room_hire_with_classes(self):
        rh_type = mommy.make_recipe('booking.event_type_RH')
        form = EventAdminForm(data=self.form_data(), ev_type='EV')
        ev_type_field = form.fields['event_type']
        self.assertEqual(
            set(EventType.objects.filter(id=self.event_type_ev.id)),
            set(ev_type_field.queryset))
        self.assertEquals(len(ev_type_field.queryset), 1)

        form = EventAdminForm(data=self.form_data(), ev_type='CL')
        ev_type_field = form.fields['event_type']
        self.assertEqual(
            set(
                EventType.objects.filter(id__in=[
                    self.event_type.id, self.event_type_oc.id, rh_type.id
                ])), set(ev_type_field.queryset))
        self.assertEquals(len(ev_type_field.queryset), 3)
示例#22
0
    def test_form_for_cancelled_events(self):
        event = mommy.make_recipe('booking.future_PC', event_type=self.event_type)
        data = {
            'id': event.id,
            'name': event.name,
            'event_type': self.event_type.id,
            'date': event.date.astimezone(
                pytz.timezone('Europe/London')
            ).strftime('%d %b %Y %H:%M'),
            'contact_email': event.contact_email,
            'contact_person': event.contact_person,
            'cancellation_period': event.cancellation_period,
            'location': event.location,
            'allow_booking_cancellation': True,
            'paypal_email': event.paypal_email,
        }
        form = EventAdminForm(data=data, instance=event, ev_type='CL')
        self.assertTrue(form.is_valid())
        # event is not cancelled, so cancelled checkbox is hidden
        cancelled_field = form.fields['cancelled']
        self.assertEqual(
            cancelled_field.widget.attrs,
            {'disabled': 'disabled', 'id': 'cancelled_id', 'class': 'hide'}
        )
        self.assertEquals(
            cancelled_field.help_text,
            'To cancel, use the Cancel button on the class list page'
        )

        event.cancelled = True
        event.save()
        data.update({'cancelled': True})
        form = EventAdminForm(data=data, instance=event, ev_type='CL')
        cancelled_field = form.fields['cancelled']
        self.assertTrue(form.is_valid())
        self.assertEqual(
            cancelled_field.widget.attrs,
            {'class': 'form-control regular-checkbox', 'id': 'cancelled_id'}
        )
        self.assertEquals(
            cancelled_field.help_text,
            'Untick to reopen class; note that this does not change any other '
            'attributes and does not reopen previously cancelled bookings.  '
            'Class will be reopened with both booking and payment CLOSED'
        )
示例#23
0
    def test_payment_due_date_requires_advance_payment_req(self):
        form = EventAdminForm(
            data=self.form_data(
                {
                    'advance_payment_required': False,
                    'payment_due_date': '01 Jun 2015',
                    'cost': 1,
                },
            ),
            ev_type='CL'
        )
        self.assertFalse(form.is_valid())

        self.assertIn(
            'To specify a payment due date, please also tick '
            '"advance payment required&quot',
            str(form.errors['payment_due_date'])
        )
示例#24
0
    def test_form_for_cancelled_events(self):
        event = mommy.make_recipe('booking.future_PC',
                                  event_type=self.event_type)
        data = {
            'id':
            event.id,
            'name':
            event.name,
            'event_type':
            self.event_type.id,
            'date':
            event.date.astimezone(
                pytz.timezone('Europe/London')).strftime('%d %b %Y %H:%M'),
            'contact_email':
            event.contact_email,
            'contact_person':
            event.contact_person,
            'cancellation_period':
            event.cancellation_period,
            'location':
            event.location,
            'allow_booking_cancellation':
            True,
            'paypal_email':
            event.paypal_email,
        }
        form = EventAdminForm(data=data, instance=event, ev_type='CL')
        self.assertTrue(form.is_valid())
        # event is not cancelled, so cancelled checkbox is hidden
        cancelled_field = form.fields['cancelled']
        self.assertEqual(cancelled_field.widget.attrs, {
            'disabled': 'disabled',
            'id': 'cancelled_id',
            'class': 'hide'
        })
        self.assertEquals(
            cancelled_field.help_text,
            'To cancel, use the Cancel button on the class list page')

        event.cancelled = True
        event.save()
        data.update({'cancelled': True})
        form = EventAdminForm(data=data, instance=event, ev_type='CL')
        cancelled_field = form.fields['cancelled']
        self.assertTrue(form.is_valid())
        self.assertEqual(cancelled_field.widget.attrs, {
            'class': 'form-control regular-checkbox',
            'id': 'cancelled_id'
        })
        self.assertEquals(
            cancelled_field.help_text,
            'Untick to reopen class; note that this does not change any other '
            'attributes and does not reopen previously cancelled bookings.  '
            'Class will be reopened with both booking and payment CLOSED')
示例#25
0
    def test_adv_payment_due_date_and_time_allowed_require_event_cost(self):
        form = EventAdminForm(data=self.form_data(
            {
                'advance_payment_required': True,
                'cost': ''
            }, ),
                              ev_type='CL')
        self.assertFalse(form.is_valid())
        self.assertIn(
            'The following fields require a cost greater than £0: '
            'advance payment required', str(form.errors['cost']))

        form = EventAdminForm(data=self.form_data(
            {
                'payment_due_date': '01 Jun 2015',
                'advance_payment_required': True,
                'cost': ''
            }, ),
                              ev_type='CL')
        self.assertFalse(form.is_valid())
        self.assertIn(
            'The following fields require a cost greater than £0: '
            'advance payment required, payment due date',
            str(form.errors['cost']))

        form = EventAdminForm(data=self.form_data(
            {
                'payment_time_allowed': 4,
                'advance_payment_required': True,
                'cost': ''
            }, ),
                              ev_type='CL')
        self.assertFalse(form.is_valid())
        self.assertIn(
            'The following fields require a cost greater than £0: '
            'advance payment required, payment time allowed',
            str(form.errors['cost']))
示例#26
0
    def test_adv_payment_due_date_and_time_allowed_require_event_cost(self):
        form = EventAdminForm(
            data=self.form_data(
                {
                    'advance_payment_required': True,
                    'cost': ''
                },
            ),
            ev_type='CL'
        )
        self.assertFalse(form.is_valid())
        self.assertIn(
            'The following fields require a cost greater than £0: '
            'advance payment required',
            str(form.errors['cost'])
        )

        form = EventAdminForm(
            data=self.form_data(
                {
                    'payment_due_date': '01 Jun 2015',
                    'advance_payment_required': True,
                    'cost': ''
                },
            ),
            ev_type='CL'
        )
        self.assertFalse(form.is_valid())
        self.assertIn(
            'The following fields require a cost greater than £0: '
            'advance payment required, payment due date',
            str(form.errors['cost'])
        )

        form = EventAdminForm(
            data=self.form_data(
                {
                    'payment_time_allowed': 4,
                    'advance_payment_required': True,
                    'cost': ''
                },
            ),
            ev_type='CL'
        )
        self.assertFalse(form.is_valid())
        self.assertIn(
            'The following fields require a cost greater than £0: '
            'advance payment required, payment time allowed',
            str(form.errors['cost'])
        )
示例#27
0
    def test_paypal_email_and_check_must_match(self):
        form = EventAdminForm(data=self.form_data(
            {
                'paypal_email': '*****@*****.**',
                'paypal_email_check': '*****@*****.**'
            }, ),
                              ev_type='CL')
        self.assertFalse(form.is_valid())
        self.assertIn('Email addresses do not match',
                      str(form.errors['paypal_email_check']))
        self.assertIn('Email addresses do not match',
                      str(form.errors['paypal_email']))

        form = EventAdminForm(data=self.form_data(
            {
                'paypal_email': '*****@*****.**',
                'paypal_email_check': '*****@*****.**'
            }, ),
                              ev_type='CL')
        self.assertTrue(form.is_valid())
示例#28
0
    def test_adv_payment_req_requires_due_date_or_time_or_cancel_period(self):
        form = EventAdminForm(
            data=self.form_data(
                {
                    'advance_payment_required': True,
                    'cancellation_period': 0,
                    'cost': 1,
                },
            ),
            ev_type='CL'
        )
        self.assertFalse(form.is_valid())
        self.assertIn(
            'Please provide a payment due date, payment time allowed or '
            'cancellation period',
            str(form.errors['advance_payment_required'])
        )

        form = EventAdminForm(
            data=self.form_data(
                {
                    'advance_payment_required': True,
                    'payment_due_date': '30 Jun 2015',
                    'payment_time_allowed': 4,
                    'cancellation_period': 1,
                    'cost': 1,
                },
            ),
            ev_type='CL'
        )
        self.assertFalse(form.is_valid())
        self.assertIn(
            'Please provide payment due date OR payment time '
            'allowed (but not both)',
            str(form.errors['payment_due_date'])
        )
        self.assertIn(
            'Please provide payment due date OR payment time '
            'allowed (but not both)',
            str(form.errors['payment_time_allowed'])
        )

        form = EventAdminForm(
            data=self.form_data(
                {
                    'advance_payment_required': True,
                    'payment_due_date': '01 Jun 2015',
                    'cancellation_period': 1,
                    'cost': 1,
                },
            ),
            ev_type='CL'
        )
        self.assertTrue(form.is_valid())

        form = EventAdminForm(
            data=self.form_data(
                {
                    'advance_payment_required': True,
                    'payment_time_allowed': 4,
                    'cancellation_period': 1,
                    'cost': 1,
                },
            ),
            ev_type='CL'
        )
        self.assertTrue(form.is_valid())
示例#29
0
 def test_invalid_payment_due_date(self):
     form = EventAdminForm(
         data=self.form_data(
             {'payment_due_date': '31 Jun 2015'}), ev_type='CL')
     self.assertFalse(form.is_valid())
     self.assertIn('Invalid date format', str(form.errors['payment_due_date']))
示例#30
0
 def test_invalid_date(self):
     form = EventAdminForm(
         data=self.form_data(
             {'date': '15 Jun 2015 25:00'}), ev_type='CL')
     self.assertFalse(form.is_valid())
     self.assertIn('Invalid date format', str(form.errors['date']))
示例#31
0
 def test_invalid_date(self):
     form = EventAdminForm(data=self.form_data(
         {'date': '15 Jun 2015 25:00'}),
                           ev_type='CL')
     self.assertFalse(form.is_valid())
     self.assertIn('Invalid date format', str(form.errors['date']))
示例#32
0
    def test_form_valid(self):

        form = EventAdminForm(data=self.form_data(), ev_type='CL')
        self.assertTrue(form.is_valid())
示例#33
0
 def test_form_valid(self):
     form = EventAdminForm(data=self.form_data(), ev_type='CL')
     self.assertTrue(form.is_valid())
示例#34
0
    def test_adv_payment_req_requires_due_date_or_time_or_cancel_period(self):
        form = EventAdminForm(data=self.form_data(
            {
                'advance_payment_required': True,
                'cancellation_period': 0,
                'cost': 1,
            }, ),
                              ev_type='CL')
        self.assertFalse(form.is_valid())
        self.assertIn(
            'Please provide a payment due date, payment time allowed or '
            'cancellation period',
            str(form.errors['advance_payment_required']))

        form = EventAdminForm(data=self.form_data(
            {
                'advance_payment_required': True,
                'payment_due_date': '30 Jun 2015',
                'payment_time_allowed': 4,
                'cancellation_period': 1,
                'cost': 1,
            }, ),
                              ev_type='CL')
        self.assertFalse(form.is_valid())
        self.assertIn(
            'Please provide payment due date OR payment time '
            'allowed (but not both)', str(form.errors['payment_due_date']))
        self.assertIn(
            'Please provide payment due date OR payment time '
            'allowed (but not both)', str(form.errors['payment_time_allowed']))

        form = EventAdminForm(data=self.form_data(
            {
                'advance_payment_required': True,
                'payment_due_date': '01 Jun 2015',
                'cancellation_period': 1,
                'cost': 1,
            }, ),
                              ev_type='CL')
        self.assertTrue(form.is_valid())

        form = EventAdminForm(data=self.form_data(
            {
                'advance_payment_required': True,
                'payment_time_allowed': 4,
                'cancellation_period': 1,
                'cost': 1,
            }, ),
                              ev_type='CL')
        self.assertTrue(form.is_valid())