|
|
@@ -81,6 +81,16 @@ class ChildProductTests(ProductTests):
|
|
81
|
81
|
product_class=self.product_class,
|
|
82
|
82
|
structure=Product.PARENT,
|
|
83
|
83
|
is_discountable=False)
|
|
|
84
|
+ ProductAttribute.objects.create(
|
|
|
85
|
+ product_class=self.product_class,
|
|
|
86
|
+ name='The first attribute',
|
|
|
87
|
+ code='first_attribute',
|
|
|
88
|
+ type='text')
|
|
|
89
|
+ ProductAttribute.objects.create(
|
|
|
90
|
+ product_class=self.product_class,
|
|
|
91
|
+ name='The second attribute',
|
|
|
92
|
+ code='second_attribute',
|
|
|
93
|
+ type='text')
|
|
84
|
94
|
|
|
85
|
95
|
def test_child_products_dont_need_titles(self):
|
|
86
|
96
|
Product.objects.create(
|
|
|
@@ -104,6 +114,43 @@ class ChildProductTests(ProductTests):
|
|
104
|
114
|
structure=Product.CHILD)
|
|
105
|
115
|
self.assertEqual(set([self.parent]), set(Product.objects.browsable()))
|
|
106
|
116
|
|
|
|
117
|
+ def test_child_products_attribute_values(self):
|
|
|
118
|
+ product = Product.objects.create(
|
|
|
119
|
+ product_class=self.product_class, parent=self.parent,
|
|
|
120
|
+ structure=Product.CHILD)
|
|
|
121
|
+
|
|
|
122
|
+ self.parent.attr.first_attribute = "klats"
|
|
|
123
|
+ product.attr.second_attribute = "henk"
|
|
|
124
|
+ self.parent.save()
|
|
|
125
|
+ product.save()
|
|
|
126
|
+
|
|
|
127
|
+ product = Product.objects.get(pk=product.pk)
|
|
|
128
|
+ parent = Product.objects.get(pk=self.parent.pk)
|
|
|
129
|
+
|
|
|
130
|
+ self.assertEqual(parent.get_attribute_values().count(), 1)
|
|
|
131
|
+ self.assertEqual(product.get_attribute_values().count(), 2)
|
|
|
132
|
+ self.assertTrue(hasattr(parent.attr, "first_attribute"))
|
|
|
133
|
+ self.assertFalse(hasattr(parent.attr, "second_attribute"))
|
|
|
134
|
+ self.assertTrue(hasattr(product.attr, "first_attribute"))
|
|
|
135
|
+ self.assertTrue(hasattr(product.attr, "second_attribute"))
|
|
|
136
|
+
|
|
|
137
|
+ def test_child_products_attribute_values_no_parent_values(self):
|
|
|
138
|
+ product = Product.objects.create(
|
|
|
139
|
+ product_class=self.product_class, parent=self.parent,
|
|
|
140
|
+ structure=Product.CHILD)
|
|
|
141
|
+
|
|
|
142
|
+ product.attr.second_attribute = "henk"
|
|
|
143
|
+ product.save()
|
|
|
144
|
+
|
|
|
145
|
+ product = Product.objects.get(pk=product.pk)
|
|
|
146
|
+
|
|
|
147
|
+ self.assertEqual(self.parent.get_attribute_values().count(), 0)
|
|
|
148
|
+ self.assertEqual(product.get_attribute_values().count(), 1)
|
|
|
149
|
+ self.assertFalse(hasattr(self.parent.attr, "first_attribute"))
|
|
|
150
|
+ self.assertFalse(hasattr(self.parent.attr, "second_attribute"))
|
|
|
151
|
+ self.assertFalse(hasattr(product.attr, "first_attribute"))
|
|
|
152
|
+ self.assertTrue(hasattr(product.attr, "second_attribute"))
|
|
|
153
|
+
|
|
107
|
154
|
|
|
108
|
155
|
class TestAChildProduct(TestCase):
|
|
109
|
156
|
|