Bladeren bron

Add test for creating product with attributes

It was broken without anyone noticing, as reported in #1451. My work in
PR #1441 magically fixed it, but we should still test it.

Fixes #1451.

Also sneakily fixes the wrong URL in the release notes for the previous
commit.
master
Maik Hoepfel 11 jaren geleden
bovenliggende
commit
05ebbe6c5d
2 gewijzigde bestanden met toevoegingen van 23 en 2 verwijderingen
  1. 1
    1
      docs/source/releases/v0.8.rst
  2. 22
    1
      tests/functional/dashboard/catalogue_tests.py

+ 1
- 1
docs/source/releases/v0.8.rst Bestand weergeven

@@ -242,7 +242,7 @@ Minor changes
242 242
   ``JQuery UI`` as it's in use in the frontend.
243 243
 
244 244
 .. _django-tables2: http://django-tables2.readthedocs.org/en/latest/
245
-.. _bootstrap-datetimepicker: http://jdewit.github.io/bootstrap-timepicker/
245
+.. _bootstrap-datetimepicker: http://www.malot.fr/bootstrap-datetimepicker/
246 246
 
247 247
 .. _incompatible_changes_in_0.8:
248 248
 

+ 22
- 1
tests/functional/dashboard/catalogue_tests.py Bestand weergeven

@@ -2,7 +2,7 @@ from oscar.core.loading import get_model
2 2
 from django.core.urlresolvers import reverse
3 3
 
4 4
 from oscar.test.testcases import WebTestCase, add_permissions
5
-from oscar.test.factories import create_product, create_stockrecord
5
+from oscar.test.factories import create_product, create_stockrecord, ProductAttributeFactory
6 6
 
7 7
 from django_dynamic_fixture import G
8 8
 
@@ -90,6 +90,22 @@ class TestAStaffUser(WebTestCase):
90 90
             if product.has_stockrecords:
91 91
                 self.fail('Product has stock records but should not')
92 92
 
93
+    def test_can_create_product_with_required_attributes(self):
94
+        category = G(Category)
95
+        attribute = ProductAttributeFactory(required=True)
96
+        product_class = attribute.product_class
97
+        page = self.get(reverse('dashboard:catalogue-product-create',
98
+                                args=(product_class.slug,)))
99
+        form = page.form
100
+        form['upc'] = '123456'
101
+        form['title'] = 'new product'
102
+        form['attr_weight'] = '5'
103
+        form['productcategory_set-0-category'] = category.id
104
+
105
+        page = form.submit()
106
+
107
+        self.assertEqual(Product.objects.count(), 1)
108
+
93 109
     def test_can_delete_an_individual_product(self):
94 110
         product = create_product()
95 111
         stockrecord = create_stockrecord(product, partner_users=[self.user, ])
@@ -174,12 +190,17 @@ class TestANonStaffUser(TestAStaffUser):
174 190
         assert product1 in products_on_page
175 191
         assert product2 not in products_on_page
176 192
 
193
+    # Tests below can't work because they don't create a stockrecord
194
+
177 195
     def test_can_create_a_product_without_stockrecord(self):
178 196
         pass
179 197
 
180 198
     def test_can_update_a_product_without_stockrecord(self):
181 199
         pass
182 200
 
201
+    def test_can_create_product_with_required_attributes(self):
202
+        pass
203
+
183 204
     def test_can_submit_an_invalid_product_update_and_returns_to_update_page(self):
184 205
         pass
185 206
 

Laden…
Annuleren
Opslaan