Exemple #1
0
 def display_variant(self, attributes=None):
     if attributes is None:
         attributes = self.product.attributes.all()
     values = get_attributes_display_map(self, attributes).values()
     if values:
         return ', '.join([smart_text(value) for value in values])
     else:
         return smart_text(self)
Exemple #2
0
 def display_variant(self, attributes=None):
     if attributes is None:
         attributes = self.product.attributes.all()
     values = get_attributes_display_map(self, attributes).values()
     if values:
         return ', '.join([smart_text(value) for value in values])
     else:
         return smart_text(self)
Exemple #3
0
def test_get_attributes_display_map_no_choices(product_in_stock):
    attributes = product_in_stock.product_class.product_attributes.all()
    product_attr = attributes.first()

    product_in_stock.set_attribute(product_attr.pk, -1)
    attributes_display_map = get_attributes_display_map(
        product_in_stock, attributes)

    assert attributes_display_map == {product_attr.pk: smart_text(-1)}
Exemple #4
0
def test_get_attributes_display_map_no_choices(product_in_stock):
    attributes = product_in_stock.product_class.product_attributes.all()
    product_attr = attributes.first()

    product_in_stock.set_attribute(product_attr.pk, -1)
    attributes_display_map = get_attributes_display_map(
        product_in_stock, attributes)

    assert attributes_display_map == {product_attr.pk: smart_text(-1)}
Exemple #5
0
def test_get_attributes_display_map_no_choices(product_in_stock):
    attributes = product_in_stock.product_type.product_attributes.all()
    product_attr = attributes.first()

    product_in_stock.attributes[str(product_attr.pk)] = '-1'
    attributes_display_map = get_attributes_display_map(
        product_in_stock, attributes)

    assert attributes_display_map == {product_attr.pk: '-1'}
Exemple #6
0
def test_get_attributes_display_map(product_in_stock):
    attributes = product_in_stock.product_class.product_attributes.all()
    attributes_display_map = get_attributes_display_map(
        product_in_stock, attributes)

    product_attr = product_in_stock.product_class.product_attributes.first()
    attr_value = product_attr.values.first()

    assert len(attributes_display_map) == 1
    assert attributes_display_map == {product_attr.pk: attr_value}
Exemple #7
0
def test_get_attributes_display_map(product_in_stock):
    attributes = product_in_stock.product_class.product_attributes.all()
    attributes_display_map = get_attributes_display_map(
        product_in_stock, attributes)

    product_attr = product_in_stock.product_class.product_attributes.first()
    attr_value = product_attr.values.first()

    assert len(attributes_display_map) == 1
    assert attributes_display_map == {product_attr.pk: attr_value}
Exemple #8
0
def test_get_attributes_display_map_empty(product_with_no_attributes):
    product = product_with_no_attributes
    attributes = product.product_class.product_attributes.all()

    assert get_attributes_display_map(product, attributes) == {}
Exemple #9
0
def test_get_attributes_display_map_empty(product_with_no_attributes):
    product = product_with_no_attributes
    attributes = product.product_class.product_attributes.all()

    assert get_attributes_display_map(product, attributes) == {}