def test_variationdict(self): i = Item.objects.create(event=self.event, name='Dummy', default_price=0) self.p_size.item = i self.p_size.save() iv = ItemVariation.objects.create(item=i) iv.values.add(self.pv_size_s) variations = i.get_all_variations() for vd in variations: for i, v in vd.relevant_items(): self.assertIs(type(v), PropertyValue) for v in vd.relevant_values(): self.assertIs(type(v), PropertyValue) if vd[self.p_size.pk] == self.pv_size_s: vd1 = vd vd2 = VariationDict() vd2[self.p_size.pk] = self.pv_size_s self.assertEqual(vd2.identify(), vd1.identify()) self.assertEqual(vd2, vd1) vd2[self.p_size.pk] = self.pv_size_m self.assertNotEqual(vd2.identify(), vd.identify()) self.assertNotEqual(vd2, vd1) vd3 = vd2.copy() self.assertEqual(vd3, vd2) vd2[self.p_size.pk] = self.pv_size_s self.assertNotEqual(vd3, vd2) vd4 = VariationDict() vd4[4] = 'b' vd4[2] = 'a' self.assertEqual(vd4.ordered_values(), ['a', 'b'])