Exemplo 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,
     )
Exemplo 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,
     )
Exemplo 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,
     )
Exemplo 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,
     )
Exemplo n.º 5
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
Exemplo n.º 6
0
 def test_invalid_type(self):
     assert process_timestamp({}, self.meta) is None
Exemplo n.º 7
0
 def test_invalid_numeric_timestamp(self):
     assert process_timestamp('100000000000000000000.0', self.meta) is None
     assert len(list(self.meta.iter_errors())) == 1
Exemplo n.º 8
0
 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
Exemplo n.º 9
0
 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
Exemplo n.º 10
0
 def test_invalid_timestamp(self):
     assert process_timestamp('foo', self.meta) is None
     assert len(list(self.meta.iter_errors())) == 1
Exemplo 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
Exemplo n.º 12
0
def test_future_timestamp():
    with pytest.raises(InvalidTimestamp):
        process_timestamp('2052-01-01T10:30:45Z')
Exemplo n.º 13
0
def test_invalid_numeric_timestamp():
    with pytest.raises(InvalidTimestamp):
        process_timestamp('100000000000000000000.0')
Exemplo n.º 14
0
def test_invalid_timestamp():
    with pytest.raises(InvalidTimestamp):
        process_timestamp('foo')
Exemplo 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