Skip to content

Commit

Permalink
Update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
goanpeca committed Apr 27, 2020
1 parent d29016b commit 46820a5
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 9 deletions.
6 changes: 3 additions & 3 deletions colosseum/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ def value(self, context):
BACKGROUND_COLOR_CHOICES = Choices(default, TRANSPARENT, validators=[is_color])

# background_image
BACKGROUND_IMAGE_CHOICES = Choices(validators=[is_uri], explicit_defaulting_constants=[INHERIT])
BACKGROUND_IMAGE_CHOICES = Choices(None, validators=[is_uri], explicit_defaulting_constants=[INHERIT, INITIAL])

# background_repeat
REPEAT = 'repeat'
Expand All @@ -364,10 +364,10 @@ def value(self, context):
SCROLL = 'scroll'
FIXED = 'fixed'

BACKGROUND_ATTACHMENT_CHOICES = Choices(SCROLL, FIXED, explicit_defaulting_constants=[INHERIT])
BACKGROUND_ATTACHMENT_CHOICES = Choices(SCROLL, FIXED, explicit_defaulting_constants=[INHERIT, INITIAL])

# background_position
BACKGROUND_POSITION_CHOICES = Choices(validators=is_position, explicit_defaulting_constants=[INHERIT])
BACKGROUND_POSITION_CHOICES = Choices(validators=[is_position], explicit_defaulting_constants=[INHERIT])

# background

Expand Down
4 changes: 2 additions & 2 deletions colosseum/declaration.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
)
from .exceptions import ValidationError
from .wrappers import (
Border, BorderBottom, BorderLeft, BorderRight, BorderTop, Outline,
Background, Border, BorderBottom, BorderLeft, BorderRight, BorderTop,
Outline,
)

_CSS_PROPERTIES = set()
Expand Down Expand Up @@ -115,7 +116,6 @@ def validated_property(name, choices, initial):
# Check the value attribute is a callable
if not callable(value_attr):
raise ValueError('Initial value "%s" `value` attribute is not callable!' % initial)

except AttributeError:
raise ValueError('Initial value "%s" does not have a value attribute!' % initial)

Expand Down
8 changes: 4 additions & 4 deletions colosseum/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,7 @@ def position(value):
##############################################################################
# Background shorthand
##############################################################################
def _parse_background_property_part(value, outline_dict):
def _parse_background_property_part(value, background_dict):
"""Parse background shorthand property part for known properties."""
from .constants import ( # noqa
BACKGROUND_ATTACHMENT_CHOICES, BACKGROUND_COLOR_CHOICES, BACKGROUND_IMAGE_CHOICES,
Expand All @@ -527,11 +527,11 @@ def _parse_background_property_part(value, outline_dict):
except (ValueError, ValidationError):
continue

if property_name in border_dict:
if property_name in background_dict:
raise ValueError('Invalid duplicated property!')

border_dict[property_name] = value
return border_dict
background_dict[property_name] = value
return background_dict

raise ValueError('Background value "{value}" not valid!'.format(value=value))

Expand Down
1 change: 1 addition & 0 deletions colosseum/validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ def is_cursor(value):
except ValueError as error:
raise ValidationError(str(error))

return value

is_cursor.description = ('[ [<uri> ,]* [ auto | crosshair | default | pointer | move | e-resize '
'| ne-resize | nw-resize | n-resize | se-resize | sw-resize | s-resize '
Expand Down
5 changes: 5 additions & 0 deletions colosseum/wrappers.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,11 @@ class Border(Shorthand):
VALID_KEYS = ['border_width', 'border_style', 'border_color']


class Background(Shorthand):
VALID_KEYS = ['background_color', 'background_image', 'background_repeat', 'background_attachment',
'background_position']


class Uri:
"""Wrapper for a url."""

Expand Down

0 comments on commit 46820a5

Please sign in to comment.