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