Beispiel #1
0
 def test_get_happy_path(self):
     self.client.login(username='******', password='******')
     response = self.client.get(self.url)
     assert_ok(response)
     formset_ = response.context['ingredient_formset']
     ingredient_names = [f.initial.get('ingredient_name') for f in formset_]
     self.assertIn(self.sauvin.name, ingredient_names)
Beispiel #2
0
def test_howto_view():
    content = "<p>Testing 123</p>"
    block = FlatBlock.objects.create(slug="test.howto", header="Test Heading", content=content)
    client = Client()
    response = client.get(reverse("main.views.howto", kwargs=dict(name="test.howto")))
    assert_ok(response)
    assert_in("Test Heading", str(response.content))
    assert_in(content, str(response.content))
Beispiel #3
0
 def test(self):
     self.assertTrue(self.client.login(username='******', password='******'))
     order = SupplierOrder.objects.create(
         supplier=self.gladfields,
         status=SupplierOrder.STATUS_ORDERED)
     OrderItem.objects.filter(supplier_order=None, ingredient__supplier=self.gladfields).update(supplier_order=order)
     response = self.client.get(reverse('supplier_order_summary_csv', args=(order.id,)))
     assert_ok(response)
     self.assertEqual(mimetypes.types_map['.csv'], response['Content-Type'])
     self.assertEqual('attachment; filename="Gladfields_order.csv"', response['Content-Disposition'])
     response_body = response.content.decode(encoding='UTF-8')
     f = StringIO(response_body)
     reader = csv.reader(f)
     self.assertIn(["Name", "Unit Size", "Quantity"], reader)
     self.assertIn(["Munich", "sack", "12"], reader)
Beispiel #4
0
    def test_happy_path(self):
        self._login()
        # Add some hops to cart:
        response = self.app.get(ORDER_HOPS_URL)
        add_grain_to_order_form = response.forms.get(0)
        add_grain_to_order_form['ingredients-0-quantity'] = 5
        response = add_grain_to_order_form.submit()
        self.assertRedirects(response, ORDER_HOPS_URL)
        response = response.follow()

        cart_form = response.forms.get(1)
        self.assertEqual(str(self.sauvin.id), cart_form.get('cart-0-ingredient').value)
        self.assertEqual('5', cart_form.get('cart-0-quantity').value)

        # delete from cart:
        params=cart_form.submit_fields()
        params.append(('ingredient_id', self.sauvin.id))
        response.goto(reverse('remove_item'), method='post', params=params)
        assert_ok(response)
        response = self.app.get(ORDER_HOPS_URL)
        cart_form = response.forms.get(1)
        self.assertNotIn('cart-0-ingredient', cart_form.fields)