Skip to content

Commit

Permalink
Added exclusive unit testing
Browse files Browse the repository at this point in the history
  • Loading branch information
joamag committed Dec 3, 2019
1 parent dcedd2c commit 3cdcd29
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/budy/models/product.py
Expand Up @@ -1027,7 +1027,7 @@ def _reset_labels(self):
self.labels = []

def _build_labels(self, groups):
if not isinstance(groups, (list, tuple)):
if not isinstance(groups, (list, tuple, appier.References)):
groups = (groups,) if groups else []
for group in groups:
for label in group.labels:
Expand Down
17 changes: 17 additions & 0 deletions src/budy/test/product.py
Expand Up @@ -240,6 +240,23 @@ def test_labels(self):
self.assertEqual(len(product.collections), 1)
self.assertEqual(product.collections[0].id, collection.id)

collection.exclusive = True
collection.save()

self.assertEqual(product.labels, ["new_in"])
self.assertEqual(len(product.collections), 1)
self.assertEqual(product.collections[0].id, collection.id)
self.assertEqual(collection.new_in, True)
self.assertEqual(collection.exclusive, True)
self.assertEqual(collection.labels, ["new_in", "exclusive"])

product = product.reload()
product.save()

self.assertEqual(product.labels, ["new_in", "exclusive"])
self.assertEqual(len(product.collections), 1)
self.assertEqual(product.collections[0].id, collection.id)

def test_discount(self):
product = budy.Product(
short_description = "product",
Expand Down

0 comments on commit 3cdcd29

Please sign in to comment.