Example #1
0
  def _UpdateCodeCoverageSettings(self, code_coverage_is_on, user, message):
    """Updates the code coverage settings.

    Args:
      code_coverage_is_on (bool): Whether the code coverage feature is turned
                                  on.
      user: User who initiated the update.
      message: The update message.

    Returns:
      A bool indicates whether the update is successful.
    """
    code_coverage_settings = waterfall_config.GetCodeCoverageSettings()
    if code_coverage_is_on == code_coverage_settings.get(
        'serve_presubmit_coverage_data'):
      return False

    code_coverage_settings = copy.deepcopy(code_coverage_settings)
    code_coverage_settings[
        'serve_presubmit_coverage_data'] = code_coverage_is_on
    return wf_config.FinditConfig.Get().Update(
        user,
        acl.IsPrivilegedUser(user.email(), users.is_current_user_admin()),
        message=message,
        code_coverage_settings=code_coverage_settings)
Example #2
0
  def _UpdateActionSettings(self, auto_commit_revert_is_on, user, message):
    """Updates the action settings.

    Args:
      auto_commit_revert_is_on (bool): Whether the auto commit revert feature is
                                       turned on.
      user: User who initiated the update.
      message: The update message.

    Returns:
      A bool indicates whether the update is successful.
    """
    action_settings = waterfall_config.GetActionSettings()
    if auto_commit_revert_is_on == action_settings.get('auto_commit_revert'):
      return False

    updated_action_settings = copy.deepcopy(action_settings)
    updated_action_settings['auto_commit_revert'] = auto_commit_revert_is_on
    return wf_config.FinditConfig.Get().Update(
        user,
        acl.IsPrivilegedUser(user.email(), users.is_current_user_admin()),
        message=message,
        action_settings=updated_action_settings)
Example #3
0
 def testGooglerIsPrivilegedUser(self):
     self.assertTrue(acl.IsPrivilegedUser('*****@*****.**', False))
Example #4
0
 def testUnknownUserIsNotPrivilegedUser(self):
     self.assertFalse(acl.IsPrivilegedUser('*****@*****.**', False))
Example #5
0
 def testAdminIsPrivilegedUser(self):
     self.assertTrue(acl.IsPrivilegedUser('*****@*****.**', True))