# 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 Number(BaseParser):
#     """Parser to parse a number"""
# 
#     ParseException = NumberParseException
# 
#     @classmethod
#     def grammar(cls):
#         """Returns the grammar to parse a number that may have a sign and a
#         decimal point"""
#         sign = pp.Word('+-', exact=1)
#         digits = pp.Word(pp.nums)
#         decimal = pp.Combine(pp.Word('.', exact=1) + digits)
#         return pp.Combine(pp.Optional(sign) + digits + pp.Optional(decimal))
# 
#     @classmethod
#     def parse_action(cls, tokens):
#         """Returns a dictionary from the parsed tokens"""
#         return {
#             'type': ValueType.number,
#             'value': float(tokens[0])
#         }
# 
# class NumberParseException(Exception):
#     """Raised when there is an exception while parsing a number"""
#     pass


import unittest
from css2video.constants import ValueType
from css2video.parsers.value import Number, NumberParseException



class TestCase(unittest.TestCase):

    def test_parser(self):
        response = Number.parse('20')
        self.assertEqual(response, dict(type=ValueType.number, value=20.))

        response = Number.parse('+1')
        self.assertEqual(response, dict(type=ValueType.number, value=1.))


# 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 Number(BaseParser):
#     """Parser to parse a number"""
# 
#     ParseException = NumberParseException
# 
#     @classmethod
#     def grammar(cls):
#         """Returns the grammar to parse a number that may have a sign and a
#         decimal point"""
#         sign = pp.Word('+-', exact=1)
#         digits = pp.Word(pp.nums)
#         decimal = pp.Combine(pp.Word('.', exact=1) + digits)
#         return pp.Combine(pp.Optional(sign) + digits + pp.Optional(decimal))
# 
#     @classmethod
#     def parse_action(cls, tokens):
#         """Returns a dictionary from the parsed tokens"""
#         return {
#             'type': ValueType.number,
#             'value': float(tokens[0])
#         }
# 
# class NumberParseException(Exception):
#     """Raised when there is an exception while parsing a number"""
#     pass


# Path: tests/parsers/value/test_number.py
import unittest
from css2video.constants import ValueType
from css2video.parsers.value import Number, NumberParseException




class TestCase(unittest.TestCase):

    def test_parser(self):
        response = Number.parse('20')
        self.assertEqual(response, dict(type=ValueType.number, value=20.))

        response = Number.parse('+1')
        self.assertEqual(response, dict(type=ValueType.number, value=1.))


        response = Number.parse('-20.5')