Skip to content

Commit

Permalink
Update tests and release notes for updated child product editing
Browse files Browse the repository at this point in the history
Nothing major to see here. Improved the slightly horrid
TestCreateProductForm test class.
  • Loading branch information
maiksprenger committed Aug 1, 2014
1 parent d14f2ad commit 765c72e
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 15 deletions.
16 changes: 16 additions & 0 deletions docs/source/releases/v0.8.rst
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,15 @@ has been altered to be:
Some properties and method names have also been updated to the new naming. The
old ones will throw a deprecation warning.

Better handling of child products in product dashboard
------------------------------------------------------
Together with the changes above, the dashboard experience for child products
has been improved. The difference between a parent product and a stand-alone
product is hidden from the user; a user can now add and remove child products
on any suitable product. When the first child product is added, a stand-alone
product becomes a parent product; and vice versa.
In the front-end, the old name of "product variants" has been kept.

Django 1.7 support
------------------

Expand Down Expand Up @@ -289,6 +298,13 @@ the following renaming pattern:
* ``variants`` becomes ``children``
* ``variant`` becomes ``child``

Product editing
---------------
The dashboard improvements for child products meant slight changes to both
``ProductCreateUpdateView`` and ``ProductForm``. Notably, ``ProductForm`` now
gets a ``parent`` kwarg. Please review your customisations for compatibility
with the updated code.

.. _incompatible_shipping_changes_in_0.8:

Shipping
Expand Down
5 changes: 3 additions & 2 deletions oscar/test/newfactories.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@

__all__ = ["UserFactory", "CountryFactory", "UserAddressFactory",
"BasketFactory", "VoucherFactory", "ProductFactory",
"StockRecordFactory", "ProductAttributeFactory",
"ProductAttributeValueFactory", "AttributeOptionGroupFactory",
"ProductClassFactory", "StockRecordFactory",
"ProductAttributeFactory", "ProductAttributeValueFactory",
"AttributeOptionGroupFactory",
"AttributeOptionFactory", "PartnerFactory",
"ProductCategoryFactory", "CategoryFactory", "RangeFactory"]

Expand Down
2 changes: 1 addition & 1 deletion tests/functional/dashboard/catalogue_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def test_can_create_and_continue_editing_a_product(self):
form['stockrecords-0-partner_sku'] = '14'
form['stockrecords-0-num_in_stock'] = '555'
form['stockrecords-0-price_excl_tax'] = '13.99'
page = form.submit('action', index=0)
page = form.submit(name='action', value='continue')

self.assertEqual(Product.objects.count(), 1)
product = Product.objects.all()[0]
Expand Down
6 changes: 2 additions & 4 deletions tests/functional/dashboard/product_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,14 +113,12 @@ def setUp(self):
super(TestCreateChildProduct, self).setUp()

def test_categories_are_not_required(self):
url = reverse('dashboard:catalogue-product-create',
kwargs={'product_class_slug': self.pclass.slug})
url = reverse('dashboard:catalogue-product-create-child',
kwargs={'parent_pk': self.parent.pk})
page = self.get(url)

product_form = page.form
product_form['structure'] = 'child'
product_form['title'] = expected_title = 'Nice T-Shirt'
product_form['parent'] = str(self.parent.id)
product_form.submit()

try:
Expand Down
17 changes: 9 additions & 8 deletions tests/unit/dashboard/catalogue_form_tests.py
Original file line number Diff line number Diff line change
@@ -1,24 +1,25 @@
from django.test import TestCase
from django_dynamic_fixture import G

from oscar.apps.catalogue import models
from oscar.apps.dashboard.catalogue import forms
from oscar.test import factories


class TestCreateProductForm(TestCase):

def setUp(self):
self.pclass = G(models.ProductClass)
self.product_class = factories.ProductClassFactory()

def submit(self, data):
return forms.ProductForm(self.pclass, data=data)
def submit(self, data, parent=None):
return forms.ProductForm(self.product_class, parent=parent, data=data)

def test_validates_that_parent_products_must_have_title(self):
form = self.submit({'structure': 'parent'})
self.assertFalse(form.is_valid())
form = self.submit({'structure': 'parent', 'title': 'foo'})
self.assertTrue(form.is_valid())

def test_validates_that_child_products_dont_need_a_title(self):
parent = G(
models.Product, product_class=self.pclass, structure='parent')
form = self.submit({'structure': 'child', 'parent': parent.id})
parent = factories.ProductFactory(
product_class=self.product_class, structure='parent')
form = self.submit({'structure': 'child'}, parent=parent)
self.assertTrue(form.is_valid())

1 comment on commit 765c72e

@codeinthehole
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was a bit horrid - nice work.

Please sign in to comment.