# Path: css2video/constants.py
# class ValueType(object):
#     """Class to define constants for value types"""
# 
#     number = 'number'
#     length = 'length'
#     percentage = 'percentage'
#     time = 'time'
#     color = 'color'
#     text = 'text'
#     url = 'url'
#     function = 'function'
#     array = 'array'
# 
# Path: css2video/parsers/value.py
# class Percentage(BaseParser):
#     """Parse a percentage value"""
# 
#     ParseException = PercentageParseException
# 
#     @classmethod
#     def grammar(cls):
#         """Grammar to parse the percentage value"""
#         number = Number.grammar()
#         percentage = pp.Literal('%').leaveWhitespace()
#         return number + percentage
# 
#     @classmethod
#     def parse_action(cls, tokens):
#         """Returns a dictionary from the parsed tokens"""
#         return {
#             'type': ValueType.percentage,
#             'value': float(tokens[0]),
#         }
# 
# class PercentageParseException(Exception):
#     """Raised when there is an exception while parsing a percentage value"""
#     pass


import unittest
from css2video.constants import ValueType
from css2video.parsers.value import Percentage, PercentageParseException



class TestCase(unittest.TestCase):

    def test_parser(self):
        response = Percentage.parse('20%')
        self.assertEqual(
            response, dict(type=ValueType.percentage, value=20.)
        )

        response = Percentage.parse('-40.5%')
        self.assertEqual(
            response, dict(type=ValueType.percentage, value=-40.5)
        )

        with self.assertRaises(PercentageParseException):
            Percentage.parse('20')


# Path: css2video/constants.py
# class ValueType(object):
#     """Class to define constants for value types"""
# 
#     number = 'number'
#     length = 'length'
#     percentage = 'percentage'
#     time = 'time'
#     color = 'color'
#     text = 'text'
#     url = 'url'
#     function = 'function'
#     array = 'array'
# 
# Path: css2video/parsers/value.py
# class Percentage(BaseParser):
#     """Parse a percentage value"""
# 
#     ParseException = PercentageParseException
# 
#     @classmethod
#     def grammar(cls):
#         """Grammar to parse the percentage value"""
#         number = Number.grammar()
#         percentage = pp.Literal('%').leaveWhitespace()
#         return number + percentage
# 
#     @classmethod
#     def parse_action(cls, tokens):
#         """Returns a dictionary from the parsed tokens"""
#         return {
#             'type': ValueType.percentage,
#             'value': float(tokens[0]),
#         }
# 
# class PercentageParseException(Exception):
#     """Raised when there is an exception while parsing a percentage value"""
#     pass


# Path: tests/parsers/value/test_percentage.py
import unittest
from css2video.constants import ValueType
from css2video.parsers.value import Percentage, PercentageParseException




class TestCase(unittest.TestCase):

    def test_parser(self):
        response = Percentage.parse('20%')
        self.assertEqual(
            response, dict(type=ValueType.percentage, value=20.)
        )

        response = Percentage.parse('-40.5%')
        self.assertEqual(
            response, dict(type=ValueType.percentage, value=-40.5)
        )

        with self.assertRaises(PercentageParseException):
            Percentage.parse('20')


        with self.assertRaises(PercentageParseException):