-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update tests and release notes for updated child product editing
Nothing major to see here. Improved the slightly horrid TestCreateProductForm test class.
- Loading branch information
1 parent
d14f2ad
commit 765c72e
Showing
5 changed files
with
31 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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()) |
765c72e
There was a problem hiding this comment.
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.