# 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 Time(BaseParser):
#     """Parse a time value which is in seconds"""
# 
#     ParseException = TimeParseException
# 
#     @classmethod
#     def grammar(cls):
#         """Grammar to parse a time value"""
#         number = Number.grammar()
#         seconds = pp.CaselessLiteral('s').leaveWhitespace()
#         return number + seconds
# 
#     @classmethod
#     def parse_action(cls, tokens):
#         """Returns a dictionary from the parsed tokens"""
#         return {
#             'type': ValueType.time,
#             'value': float(tokens[0])
#         }
# 
# class TimeParseException(Exception):
#     """Raised when there is an execption while parsing a time value"""
#     pass


import unittest
from css2video.constants import ValueType
from css2video.parsers.value import Time, TimeParseException



class TestCase(unittest.TestCase):

    def test_parser(self):
        response = Time.parse('20s')
        self.assertEqual(
            response, dict(type=ValueType.time, value=20.)
        )

        response = Time.parse('-40.5S')
        self.assertEqual(
            response, dict(type=ValueType.time, value=-40.5)
        )

        with self.assertRaises(TimeParseException):
            Time.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 Time(BaseParser):
#     """Parse a time value which is in seconds"""
# 
#     ParseException = TimeParseException
# 
#     @classmethod
#     def grammar(cls):
#         """Grammar to parse a time value"""
#         number = Number.grammar()
#         seconds = pp.CaselessLiteral('s').leaveWhitespace()
#         return number + seconds
# 
#     @classmethod
#     def parse_action(cls, tokens):
#         """Returns a dictionary from the parsed tokens"""
#         return {
#             'type': ValueType.time,
#             'value': float(tokens[0])
#         }
# 
# class TimeParseException(Exception):
#     """Raised when there is an execption while parsing a time value"""
#     pass


# Path: tests/parsers/value/test_time.py
import unittest
from css2video.constants import ValueType
from css2video.parsers.value import Time, TimeParseException




class TestCase(unittest.TestCase):

    def test_parser(self):
        response = Time.parse('20s')
        self.assertEqual(
            response, dict(type=ValueType.time, value=20.)
        )

        response = Time.parse('-40.5S')
        self.assertEqual(
            response, dict(type=ValueType.time, value=-40.5)
        )

        with self.assertRaises(TimeParseException):
            Time.parse('20')


        with self.assertRaises(TimeParseException):