def test_valid_timestamp(self): self.assertTrue( PanoptesValidators.valid_timestamp(timestamp=time.time())) self.assertTrue( PanoptesValidators.valid_timestamp(timestamp=time.time() - 86400)) self.assertTrue( PanoptesValidators.valid_timestamp(timestamp=time.time() + 10)) self.assertTrue( PanoptesValidators.valid_timestamp(timestamp=time.time() + 70, max_skew=120)) self.assertFalse(PanoptesValidators.valid_timestamp(timestamp=0)) self.assertFalse( PanoptesValidators.valid_timestamp(timestamp=time.time() + 120)) self.assertFalse( PanoptesValidators.valid_timestamp(timestamp=time.time() - 604810)) self.assertFalse(PanoptesValidators.valid_timestamp(timestamp=None)) self.assertFalse( PanoptesValidators.valid_timestamp(timestamp=time.time(), max_age=None)) self.assertFalse( PanoptesValidators.valid_timestamp(timestamp=time.time(), max_skew=None))
def resource_set_creation_timestamp(self, timestamp): """ Sets the timestamp of the Args: timestamp (int, float): The new timestamp Returns: None Raises: AssertionError: If the passed timestamp is not an int or float or is too old or too much in the future, \ an AssertionError would be raised """ assert PanoptesValidators.valid_timestamp(timestamp), u'timestamp should be an Unix epoch int|float ' \ u'not more than 7 days old or more than 60 ' \ u'seconds in the future' self.__data[u'resource_set_creation_timestamp'] = timestamp