def test_pre_epoch(): expected = -5617641600 assert _rfc3339.parse_to_epoch("1791-12-26T00:00:00Z") == expected assert _rfc3339.parse_to_epoch("1791-12-26T00:00:00+00:00") == expected assert _rfc3339.parse_to_epoch("1791-12-26T00:00:00-00:00") == expected assert _rfc3339.parse_to_epoch("1791-12-26T01:00:00+01:00") == expected assert _rfc3339.parse_to_epoch("1791-12-25T23:00:00-01:00") == expected
def test_micros_millis(): assert _rfc3339.parse_to_epoch("1970-01-01T00:00:00Z") == pytest.approx(0) assert _rfc3339.parse_to_epoch("1970-01-01T00:00:00.1Z") == pytest.approx(0.1) assert _rfc3339.parse_to_epoch("1970-01-01T00:00:00.001Z") == pytest.approx(0.001) assert _rfc3339.parse_to_epoch("1970-01-01T00:00:00.000001Z") == pytest.approx(0.000001) assert _rfc3339.parse_to_epoch("1970-01-01T00:00:00+00:00") == pytest.approx(0) assert _rfc3339.parse_to_epoch("1970-01-01T00:00:00.1+00:00") == pytest.approx(0.1) assert _rfc3339.parse_to_epoch("1970-01-01T00:00:00.001+00:00") == pytest.approx(0.001) assert _rfc3339.parse_to_epoch("1970-01-01T00:00:00.000001+00:00") == pytest.approx(0.000001)
def test_epoch(): expected = pytest.approx(0) assert _rfc3339.parse_to_epoch("1970-01-01T00:00:00Z") == expected assert _rfc3339.parse_to_epoch("1970-01-01T00:00:00z") == expected assert _rfc3339.parse_to_epoch("1970-01-01T00:00:00+00:00") == expected assert _rfc3339.parse_to_epoch("1970-01-01T00:00:00-00:00") == expected assert _rfc3339.parse_to_epoch("1970-01-01T01:00:00+01:00") == expected assert _rfc3339.parse_to_epoch("1969-12-31T23:00:00-01:00") == expected
def user_metadata(self): """Returns additional metadata associated with this user. Returns: UserMetadata: A UserMetadata instance. Does not return None. """ def _int_or_none(key): if key in self._data: return int(self._data[key]) return None last_refresh_at_millis = None last_refresh_at_rfc3339 = self._data.get('lastRefreshAt', None) if last_refresh_at_rfc3339: last_refresh_at_millis = int(_rfc3339.parse_to_epoch(last_refresh_at_rfc3339) * 1000) return UserMetadata( _int_or_none('createdAt'), _int_or_none('lastLoginAt'), last_refresh_at_millis)
def test_bad_datestrs(datestr): with pytest.raises(ValueError): _rfc3339.parse_to_epoch(datestr)
def test_nanos(): assert _rfc3339.parse_to_epoch("1970-01-01T00:00:00.0000001Z") == pytest.approx(0)
def test_post_epoch(): expected = 904892400 assert _rfc3339.parse_to_epoch("1998-09-04T07:00:00Z") == expected assert _rfc3339.parse_to_epoch("1998-09-04T07:00:00+00:00") == expected assert _rfc3339.parse_to_epoch("1998-09-04T08:00:00+01:00") == expected assert _rfc3339.parse_to_epoch("1998-09-04T06:00:00-01:00") == expected