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, )
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_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, )
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
def test_invalid_timestamp(self): assert process_timestamp('foo', self.meta) is None assert len(list(self.meta.iter_errors())) == 1
def test_iso_timestamp(): assert process_timestamp( '2012-01-01T10:30:45', current_datetime=datetime(2012, 1, 1, 10, 30, 45), ) == 1325413845.0
def test_future_timestamp(): with pytest.raises(InvalidTimestamp): process_timestamp('2052-01-01T10:30:45Z')
def test_invalid_numeric_timestamp(): with pytest.raises(InvalidTimestamp): process_timestamp('100000000000000000000.0')
def test_invalid_timestamp(): with pytest.raises(InvalidTimestamp): process_timestamp('foo')
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