Esempio n. 1
0
 def test_timestamp_iso_timestamp_with_Z(self):
     self.assertEquals(
         process_timestamp(
             '2012-01-01T10:30:45Z',
             current_datetime=datetime(2012, 1, 1, 10, 30, 45),
         ),
         1325413845.0,
     )
Esempio n. 2
0
 def test_long_microseconds_value(self):
     self.assertEquals(
         process_timestamp(
             '2012-01-01T10:30:45.341324Z',
             current_datetime=datetime(2012, 1, 1, 10, 30, 45),
         ),
         1325413845.0,
     )
Esempio n. 3
0
 def test_timestamp_iso_timestamp_with_Z(self):
     self.assertEquals(
         process_timestamp(
             '2012-01-01T10:30:45Z',
             current_datetime=datetime(2012, 1, 1, 10, 30, 45),
         ),
         1325413845.0,
     )
Esempio n. 4
0
 def test_long_microseconds_value(self):
     self.assertEquals(
         process_timestamp(
             '2012-01-01T10:30:45.341324Z',
             current_datetime=datetime(2012, 1, 1, 10, 30, 45),
         ),
         1325413845.0,
     )
 def test_long_microseconds_value(self):
     assert process_timestamp(
         '2012-01-01T10:30:45.341324Z',
         self.meta,
         current_datetime=datetime(2012, 1, 1, 10, 30, 45),
     ) == 1325413845.0
 def test_invalid_type(self):
     assert process_timestamp({}, self.meta) is None
 def test_invalid_numeric_timestamp(self):
     assert process_timestamp('100000000000000000000.0', self.meta) is None
     assert len(list(self.meta.iter_errors())) == 1
 def test_future_timestamp(self):
     assert process_timestamp('2052-01-01T10:30:45Z', self.meta) is None
     assert len(list(self.meta.iter_errors())) == 1
 def test_timestamp_iso_timestamp_with_Z(self):
     assert process_timestamp(
         '2012-01-01T10:30:45Z',
         self.meta,
         current_datetime=datetime(2012, 1, 1, 10, 30, 45),
     ) == 1325413845.0
Esempio n. 10
0
 def test_invalid_timestamp(self):
     assert process_timestamp('foo', self.meta) is None
     assert len(list(self.meta.iter_errors())) == 1
Esempio n. 11
0
def test_iso_timestamp():
    assert process_timestamp(
        '2012-01-01T10:30:45',
        current_datetime=datetime(2012, 1, 1, 10, 30, 45),
    ) == 1325413845.0
Esempio n. 12
0
def test_future_timestamp():
    with pytest.raises(InvalidTimestamp):
        process_timestamp('2052-01-01T10:30:45Z')
Esempio n. 13
0
def test_invalid_numeric_timestamp():
    with pytest.raises(InvalidTimestamp):
        process_timestamp('100000000000000000000.0')
Esempio n. 14
0
def test_invalid_timestamp():
    with pytest.raises(InvalidTimestamp):
        process_timestamp('foo')
Esempio n. 15
0
def test_iso_timestamp_with_ms():
    assert process_timestamp(
        '2012-01-01T10:30:45.434',
        current_datetime=datetime(2012, 1, 1, 10, 30, 45, 434000),
    ) == 1325413845.0