示例#1
0
    def test_subscription_is_required_on_signup(self):

        post = {
            'plan': None,
        }
        (response, post) = signup_test_customer(post)

        errors = response.context['subscription_form'].errors
        self.assertIn('plan', errors.keys())
示例#2
0
    def test_order_fulfillment_limit(self):

        # create lots of orders to be fulfilled
        for i in range(0, 5):
            signup_test_customer()

        # set the limit really low
        maximum = SiteSetting.objects.get(key='orders.max_fulfillment_day')
        maximum.value = 1
        maximum.save()

        # make sure there are orders to be fulfilled that aren't listed
        self.future_patcher.start()
        unfilled_orders = Order.objects.filter(
            to_be_fulfilled__lte=date.today() + timedelta(days=30),  # Magic numbers... matches the 30 in setUp
            fulfilled=None)
        self.client.login(username='******', password='******')
        response = self.client.get(self.fulfillment_url)
        self.future_patcher.stop()

        self.assertTrue(len(unfilled_orders) > len(response.context['orders']))
示例#3
0
def add_test_customer(request):
    (response, post) = signup_test_customer(request.POST)

    def errors_or_none(form):
        try:
            return response.context[form].errors
        except:
            return None

    customer_form_errors = errors_or_none("customer_form")
    subscription_form_errors = errors_or_none("subscription_form")

    if response.status_code not in [200, 302]:
        messages.error(request, "Error: status_code %s" % response.status_code)

    elif customer_form_errors:
        messages.error(request, "Error: customer_form errors %s" % str(dict(customer_form_errors)))
    elif subscription_form_errors:
        messages.error(request, "Error: subscription_form errors %s" % str(dict(subscription_form_errors)))
    else:
        messages.info(request, "Test customer added")

    return redirect(reverse("admin:index"))