Пример #1
0
 def test_booking(self):
     """A simple booking."""
     today = datetime.today().date()
     next_week = today + timedelta(days=7)
     clean_and_save(BookingFactory(
         start_date=next_week,
         end_date=next_week + timedelta(days=3),
         title='Three days in the sun'
     ))
Пример #2
0
 def test_booking_in_the_past(self):
     """Cannot create a booking in the past."""
     today = datetime.today().date()
     last_week = today + timedelta(days=-7)
     with self.assertRaises(ValidationError):
         clean_and_save(BookingFactory(
             start_date=last_week,
             end_date=last_week + timedelta(days=3),
             title='Missed our holiday'
         ))
Пример #3
0
 def test_end_before_start(self):
     """Booking - start before the end!"""
     today = datetime.today().date()
     next_week = today + timedelta(days=7)
     with self.assertRaises(ValidationError):
         clean_and_save(BookingFactory(
         start_date=next_week,
         end_date=next_week + timedelta(days=-2),
         title='Two days in the sun',
         ))
Пример #4
0
 def test_start_equals_end(self):
     """Booking - start date and end date are the same!"""
     today = datetime.today().date()
     next_week = today + timedelta(days=7)
     with self.assertRaises(ValidationError):
         clean_and_save(BookingFactory(
         start_date=next_week,
         end_date=next_week,
         title='Not even one day in the sun',
         ))
Пример #5
0
def make_product_type(name, slug, **kwargs):
    defaults = dict(
        name=name,
        slug=slugify(slug),
    )
    defaults.update(kwargs)
    return clean_and_save(ProductType(**defaults))
def make_invoice(user, invoice_date, contact):
    return clean_and_save(
        Invoice(
            user=user,
            invoice_date=invoice_date,
            contact=contact,
        ))
Пример #7
0
def make_container(section, order, **kwargs):
    defaults = dict(
        section=section,
        order=order,
    )
    defaults.update(kwargs)
    return clean_and_save(Container(**defaults))
Пример #8
0
def make_moderate_state(name, **kwargs):
    defaults = dict(
        name=name,
        slug=slugify(name),
    )
    defaults.update(kwargs)
    return clean_and_save(ModerateState(**defaults))
Пример #9
0
def make_section(page, layout, **kwargs):
    defaults = dict(
        page=page,
        layout=layout,
    )
    defaults.update(kwargs)
    return clean_and_save(Section(**defaults))
Пример #10
0
def make_layout(name, **kwargs):
    defaults = dict(
        name=name,
        slug=slugify(name),
    )
    defaults.update(kwargs)
    return clean_and_save(Layout(**defaults))
def make_product_type(name, slug, **kwargs):
    defaults = dict(
        name=name,
        slug=slugify(slug),
    )
    defaults.update(kwargs)
    return clean_and_save(ProductType(**defaults))
Пример #12
0
def make_area(name, **kwargs):
    defaults = dict(
        name=name,
        slug=slugify(unicode(name)),
    )
    defaults.update(kwargs)
    return clean_and_save(Area(**defaults))
Пример #13
0
def make_area(name, **kwargs):
    defaults = dict(
        name=name,
        slug=slugify(unicode(name)),
    )
    defaults.update(kwargs)
    return clean_and_save(Area(**defaults))
Пример #14
0
def make_title(block, order, title, **kwargs):
    defaults = dict(
        block=block,
        order=order,
        title=title,
    )
    defaults.update(kwargs)
    return clean_and_save(Title(**defaults))
Пример #15
0
def make_booking(start_date, end_date, title, **kwargs):
    defaults = dict(
        start_date=start_date,
        end_date=end_date,
        title=title,
    )
    defaults.update(kwargs)
    return clean_and_save(Booking(**defaults))
Пример #16
0
def make_enquiry(email, subject, description, **kwargs):
    defaults = dict(
        email=email,
        subject=subject,
        description=description,
    )
    defaults.update(kwargs)
    return clean_and_save(Enquiry(**defaults))
Пример #17
0
def make_product_category(name, slug, product_type, **kwargs):
    defaults = dict(
        name=name,
        slug=slugify(slug),
        product_type=product_type,
    )
    defaults.update(kwargs)
    return clean_and_save(ProductCategory(**defaults))
def make_product_category(name, slug, product_type, **kwargs):
    defaults = dict(
        name=name,
        slug=slugify(slug),
        product_type=product_type,
    )
    defaults.update(kwargs)
    return clean_and_save(ProductCategory(**defaults))
Пример #19
0
def make_test_content(container, moderate_state, title, **kwargs):
    defaults = dict(
        container=container,
        moderate_state=moderate_state,
        title=title,
    )
    defaults.update(kwargs)
    return clean_and_save(TestContent(**defaults))
Пример #20
0
def make_page(name, order, **kwargs):
    defaults = dict(
        name=name,
        order=order,
        slug=slugify(name),
    )
    defaults.update(kwargs)
    return clean_and_save(Page(**defaults))
Пример #21
0
def make_story(block, site, **kwargs):
    defaults = dict(
        block=block,
    )
    defaults.update(kwargs)
    story = clean_and_save(Story(**defaults))
    story.site.add(site)
    story.save()
    return story
Пример #22
0
def make_event(block, site, **kwargs):
    defaults = dict(
        block=block,
    )
    defaults.update(kwargs)
    event = clean_and_save(Event(**defaults))
    event.site.add(site)
    event.save()
    return event
Пример #23
0
def make_enquiry(name, description, email, phone, **kwargs):
    defaults = dict(
        name=name,
        description=description,
        phone=phone,
        email=email,
    )
    defaults.update(kwargs)
    return clean_and_save(Enquiry(**defaults))
Пример #24
0
def check_payment(model_instance):
    """The 'Payment' model links to generic content."""
    # can we create a payment instance (need to set url before save).
    payment = model_instance.create_payment()
    assert payment.paymentline_set.count() > 0, "no payment lines"
    payment.url = reverse('project.home')
    payment.url_failure = reverse('project.home')
    clean_and_save(payment)
    # can the generic content be paid?
    paid = PaymentState.objects.get(slug=PaymentState.PAID)
    model_instance.payment_state
    model_instance.set_payment_state(paid)
    # do we have mail templates for paid and pay later?
    assert model_instance.mail_template_name
    # the generic content must implement 'get_absolute_url'
    model_instance.get_absolute_url()
    # the generic content must implement 'allow_pay_later'
    model_instance.allow_pay_later()
    clean_and_save(model_instance)
def make_invoice_settings(vat_rate, vat_number, name_and_address, phone_number,
                          footer):
    return clean_and_save(
        InvoiceSettings(
            vat_rate=vat_rate,
            vat_number=vat_number,
            name_and_address=name_and_address,
            phone_number=phone_number,
            footer=footer,
        ))
Пример #26
0
def make_invoice_settings(vat_rate, vat_number, name_and_address, phone_number, footer):
    return clean_and_save(
        InvoiceSettings(
            vat_rate=vat_rate,
            vat_number=vat_number,
            name_and_address=name_and_address,
            phone_number=phone_number,
            footer=footer,
        )
    )
def make_time_record(ticket, user, title, date_started, start_time, end_time,
                     billable, **kwargs):
    return clean_and_save(
        TimeRecord.objects.create(ticket=ticket,
                                  user=user,
                                  title=title,
                                  date_started=date_started,
                                  start_time=start_time,
                                  end_time=end_time,
                                  billable=billable,
                                  **kwargs))
Пример #28
0
def make_invoice_line(invoice, line_number, quantity, units, price, vat_rate, **kwargs):
    defaults = dict(
        user=invoice.user,
        invoice=invoice,
        line_number=line_number,
        quantity=quantity,
        units=units,
        price=price,
        vat_rate=vat_rate,
    )
    defaults.update(kwargs)
    return clean_and_save(InvoiceLine(**defaults))
Пример #29
0
def make_time_record(ticket, user, title, date_started, start_time, end_time, billable, **kwargs):
    return clean_and_save(
        TimeRecord.objects.create(
            ticket=ticket,
            user=user,
            title=title,
            date_started=date_started,
            start_time=start_time,
            end_time=end_time,
            billable=billable,
            **kwargs
        )
    )
def make_invoice_line(invoice, line_number, quantity, units, price, vat_rate,
                      **kwargs):
    defaults = dict(
        user=invoice.user,
        invoice=invoice,
        line_number=line_number,
        quantity=quantity,
        units=units,
        price=price,
        vat_rate=vat_rate,
    )
    defaults.update(kwargs)
    return clean_and_save(InvoiceLine(**defaults))
Пример #31
0
def check_checkout(model_instance):
    """The 'Checkout' model links to generic content."""
    # @property list valid of actions e.g. ``return [CheckoutAction.PAYMENT]``
    model_instance.checkout_actions
    # @property check the model is in the correct state for taking payment
    model_instance.checkout_can_charge
    # @property the email address of the person who is paying
    model_instance.checkout_email
    # @property ``list`` of strings
    model_instance.checkout_description
    # method called on success, passing in the checkout action
    # model_instance.checkout_mail(CheckoutAction.objects.payment)
    # @property the name of the person who is paying
    model_instance.checkout_name
    # @property the total payment
    model_instance.checkout_total
    # ``method`` to update the object to record the payment failure.
    # Called from within a transaction so you can update the model.
    # Note: This method should update the ``model_instance`` AND ``save`` it.
    model_instance.checkout_fail()
    # method returning a url
    model_instance.checkout_fail_url(1)
    # Update the object to record the payment success.
    # Called from within a transaction so you can update the model.
    # Note: This method should update the ``model_instance`` AND ``save`` it.
    # We pass in the 'checkout' so the model instance can send an email etc.
    checkout = CheckoutFactory(
        action=CheckoutAction.objects.payment,
        content_object=model_instance,
        state=CheckoutState.objects.success,
        total=Decimal('123.45'),
    )
    model_instance.checkout_success(checkout)
    # method returning a url
    model_instance.checkout_success_url(1)
    model_instance.get_absolute_url()
    clean_and_save(model_instance)
Пример #32
0
def make_story(**kwargs):
    return clean_and_save(Story(**kwargs))
Пример #33
0
def make_event_block(page_section, **kwargs):
    defaults = dict(page_section=page_section)
    defaults.update(kwargs)
    return clean_and_save(EventBlock(**defaults))
Пример #34
0
def make_invoice(user, invoice_date, contact):
    return clean_and_save(Invoice(user=user, invoice_date=invoice_date, contact=contact))
Пример #35
0
def make_story(**kwargs):
    return clean_and_save(
        Story(
            **kwargs
        )
    )
Пример #36
0
def make_title_block(page_section, **kwargs):
    defaults = dict(page_section=page_section)
    defaults.update(kwargs)
    return clean_and_save(TitleBlock(**defaults))