def setUp(self) -> None: """Set up user models in datastore for use in testing.""" super(RoleQueryAuditModelUnitTests, self).setUp() audit_models.RoleQueryAuditModel(id=self.ID, user_id=self.USER_ID, intent=feconf.ROLE_ACTION_ADD, role=self.ROLE, username=self.USERNAME).put()
def log_role_query(user_id: str, intent: str, role: Optional[str] = None, username: Optional[str] = None) -> None: """Stores the query to role structure in RoleQueryAuditModel.""" model_id = '%s.%s.%s.%s' % (user_id, int(math.floor( time.time())), intent, random.randint(0, 1000)) model = audit_models.RoleQueryAuditModel(id=model_id, user_id=user_id, intent=intent, role=role, username=username) model.update_timestamps() model.put()