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 db8137a
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 13 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
16 changes: 8 additions & 8 deletions colosseum/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ def outline(value):


##############################################################################
# # Border shorthands
# Border shorthands
##############################################################################
def _parse_border_property_part(value, border_dict, direction=None):
"""Parse border shorthand property part for known properties."""
Expand Down Expand Up @@ -472,7 +472,7 @@ def position(value):
# <length> values are allowed.
try:
return Position(horizontal=units(values[0]))
except ValueError as error:
except ValueError:
if values[0] in ['left', 'right', 'center']:
return Position(horizontal=values[0])

Expand All @@ -485,7 +485,7 @@ def position(value):
# Check first value
try:
horizontal = units(values[0])
except ValueError as error:
except ValueError:
if values[0] in ['left', 'center', 'right']:
horizontal = values[0]

Expand All @@ -495,7 +495,7 @@ def position(value):
# Check second value
try:
vertical = units(values[1])
except ValueError as error:
except ValueError:
if values[1] in ['left', 'center', 'right']:
horizontal = values[1]

Expand All @@ -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
2 changes: 2 additions & 0 deletions colosseum/validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,8 @@ 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 db8137a

Please sign in to comment.