Exemple #1
0
 def setUp(self):
     self.name = 'dateTime'
     self.dtype = DateTimeTZAware(DateTime.TZOffset(90),
                                  DateTime.TZOffset(-120))
     self.dtype_diff = Duration
     self.encoded = [
         (datetime(2014, 6, 1, 12, 30, 14,
                   123456), u'2014-06-01T09:00:14.123456-02:00'),
         (datetime(2014, 6, 1, 12, 30, 14, 123456, DateTime.TZOffset(-90)),
          u'2014-06-01T12:00:14.123456-02:00'),
         (datetime(2014, 6, 1, 12, 30, 14, 123456,
                   DateTime.UTC), u'2014-06-01T10:30:14.123456-02:00'),
     ]
     self.encoded_rejected = []
     self.parsed = [
         (datetime(2014, 6, 1, 12, 30, 14, 123456, DateTime.TZOffset(-90)),
          datetime(2014, 6, 1, 12, 0, 14, 123456, DateTime.TZOffset(-120))),
         (datetime(2014, 6, 1, 12, 30, 14, 123456),
          datetime(2014, 6, 1, 9, 0, 14, 123456, DateTime.TZOffset(-120))),
         (datetime(2014, 6, 1, 12, 30, 14, 123456, DateTime.UTC),
          datetime(2014, 6, 1, 10, 30, 14, 123456,
                   DateTime.TZOffset(-120))),
         (u'2014-06-01T12:30:14.123456-01:30',
          datetime(2014, 6, 1, 12, 0, 14, 123456, DateTime.TZOffset(-120))),
         (u'2014-06-01 12:30:14',
          datetime(2014, 6, 1, 9, 0, 14, 0, DateTime.TZOffset(-120))),
         (u'2014-06-01T00:00Z',
          datetime(2014, 5, 31, 22, 0, 0, 0, DateTime.TZOffset(-120))),
     ]
     self.parsed_rejected = []
Exemple #2
0
class TestProcess04(Component):
    """ Test processes testing time-zone aware date-time input data-type
    with automatic time-zone conversion.
    """
    implements(ProcessInterface)

    identifier = "TC04:identity:literal:datetime"
    title = "Test Case 04: Literal input date-time time-zone test."
    profiles = ["test_profile"]

    TZ_DEFAULT = DateTime.TZOffset(+90)
    TZ_TARGET = DateTime.TZOffset(-120)
    #TIME_ZONE_UTC = DateTime.UTC

    inputs = [
        ('datetime',
         LiteralData(
             "TC04:datetime",
             DateTimeTZAware(TZ_DEFAULT, TZ_TARGET),
             title="Date-time input.",
         )),
    ]

    outputs = [
        ('datetime',
         LiteralData(
             "TC04:datetime",
             DateTime,
             title="Date-time output.",
         )),
    ]

    def execute(self, **inputs):
        return inputs['datetime']
Exemple #3
0
 def setUp(self):
     vlist = [
         '2014-01-01T09:30:21Z',
         '2014-02-01T18:20:15Z',
         '2014-03-01T12:15:02Z',
     ]
     self.domain = AllowedEnum(vlist, dtype=datetime)
     self.accepted = [vlist[1], DateTime.parse(vlist[0])]
     self.rejected = [DateTime.parse('2014-01-01T12:30:00Z')]
 def setUp(self):
     vlist = [
         '2014-01-01T09:30:21Z',
         '2014-02-01T18:20:15Z',
         '2014-03-01T12:15:02Z',
     ]
     self.domain = AllowedEnum(vlist, dtype=datetime)
     self.accepted = [vlist[1], DateTime.parse(vlist[0])]
     self.rejected = [DateTime.parse('2014-01-01T12:30:00Z')]
Exemple #5
0
class TestProcess05(Component):
    """ Test processes testing time-zone aware date-time input data-type
    with automatic time-zone conversion.
    """
    implements(ProcessInterface)

    identifier = "TC05:identity:literal:datetime"
    title = "Test Case 05: Literal output date-time time-zone test."
    profiles = ["test_profile"]

    TZ_DEFAULT = DateTime.TZOffset(+90)
    TZ_TARGET = DateTime.TZOffset(-120)
    #TIME_ZONE_UTC = DateTime.UTC

    inputs = [
        ('datetime',
         LiteralData(
             "TC05:datetime",
             DateTime,
             title="Date-time input.",
         )),
    ]

    outputs = [
        ('datetime_original',
         LiteralData(
             "TC05:datetime",
             DateTime,
             title="Date-time output without modification.",
         )),
        ('datetime_aware',
         LiteralData(
             "TC05:datetime_aware",
             DateTimeTZAware(TZ_DEFAULT),
             title="Date-time output with default time-zone.",
         )),
        ('datetime_converted',
         LiteralData(
             "TC05:datetime_converted",
             DateTimeTZAware(TZ_DEFAULT, TZ_TARGET),
             title="Date-time output with default time-zone.",
         )),
    ]

    def execute(self, **inputs):
        return {
            'datetime_original': inputs['datetime'],
            'datetime_aware': inputs['datetime'],
            'datetime_converted': inputs['datetime'],
        }
Exemple #6
0
 def setUp(self):
     self.name = 'dateTime'
     self.dtype = DateTime
     self.dtype_diff = Duration
     self.encoded = [
         (datetime(2014, 6, 1, 12, 30, 14, 123456,
                   DateTime.UTC), u'2014-06-01T12:30:14.123456Z'),
         (datetime(2014, 6, 1, 12, 30, 14, 500000, DateTime.TZOffset(90)),
          u'2014-06-01T12:30:14.500000+01:30'),
         (datetime(2014, 6, 1, 12, 30, 0, 0,
                   DateTime.UTC), u'2014-06-01T12:30:00Z'),
         (datetime(2014, 6, 1, 12, 30, 0, 0), u'2014-06-01T12:30:00'),
     ]
     self.encoded_rejected = ['anything']
     self.parsed = [
         (datetime(2014, 6, 1, 11, 00, 14,
                   123456), datetime(2014, 6, 1, 11, 00, 14, 123456)),
         (datetime(2014, 6, 1, 11, 00, 14, 123456, DateTime.TZOffset(90)),
          datetime(2014, 6, 1, 11, 00, 14, 123456, DateTime.TZOffset(90))),
         (datetime(2014, 6, 1, 11, 00, 14, 123456, DateTime.UTC),
          datetime(2014, 6, 1, 11, 00, 14, 123456, DateTime.UTC)),
         (u'2014-06-01T12:30:14.123456',
          datetime(2014, 6, 1, 12, 30, 14, 123456)),
         (u'2014-06-01T12:30:14.123456Z',
          datetime(2014, 6, 1, 12, 30, 14, 123456, DateTime.UTC)),
         (u'2014-06-01T12:30:14.123456+01:30',
          datetime(2014, 6, 1, 12, 30, 14, 123456, DateTime.TZOffset(90))),
         (u'2014-06-01 12:30:14', datetime(2014, 6, 1, 12, 30, 14, 0)),
         (u'2014-06-01T00:00Z',
          datetime(2014, 6, 1, 0, 0, 0, 0, DateTime.UTC)),
     ]
     self.parsed_rejected = [
         u'anything',
         u'2014-06-01T12:30:60',
         u'2014-06-01T12:60:30',
         u'2014-06-01T24:00:00',
         u'2014-02-29T00:00',
         u'2014-13-01T00:00',
         u'2014-02-00T00:00',
         u'2014-00-01T00:00',
     ]
Exemple #7
0
 def setUp(self):
     self.domain = AllowedRange('2014-02-01T09:30:21Z',
                                '2014-03-01T18:20:15Z',
                                dtype=DateTime)
     self.accepted = [
         '2014-02-01T09:30:21Z',
         '2014-02-15T00:00:00Z',
         '2014-03-01T18:20:15Z',
     ]
     self.rejected = [
         '2014-01-01T00:00:00Z',
         DateTime.parse('2014-04-01T00:00:00Z'),
     ]
 def setUp(self):
     self.domain = AllowedRange(
         '2014-02-01T09:30:21Z', '2014-03-01T18:20:15Z', dtype=DateTime
     )
     self.accepted = [
         '2014-02-01T09:30:21Z',
         '2014-02-15T00:00:00Z',
         '2014-03-01T18:20:15Z',
     ]
     self.rejected = [
         '2014-01-01T00:00:00Z',
         DateTime.parse('2014-04-01T00:00:00Z'),
     ]