Ejemplo n.º 1
0
  def testGetService_PermissionDenied(self):
    """Test GetService raises correctly when server returns 403 error."""
    server_error = http_error.MakeDetailedHttpError(code=403, message='Error.')
    self.ExpectGetService(None, error=server_error)

    with self.assertRaisesRegex(exceptions.GetServicePermissionDeniedException,
                                r'Error.'):
      serviceusage.GetService(self.PROJECT_NAME, self.DEFAULT_SERVICE)
Ejemplo n.º 2
0
  def testGetService_Enabled(self):
    """Test GetService."""
    want = self._NewServiceConfig(
        self.PROJECT_NAME, self.DEFAULT_SERVICE, enabled=True)
    self.ExpectGetService(want)

    got = serviceusage.GetService(self.PROJECT_NAME, self.DEFAULT_SERVICE)

    self.assertEqual(got, want)
Ejemplo n.º 3
0
def IsServiceEnabled(project_id, service_name):
    """Return true if the service is enabled.

  Args:
    project_id: The ID of the project we want to query.
    service_name: The name of the service.

  Raises:
    exceptions.GetServicesPermissionDeniedException: if a 403 or 404
        error is returned by the Get request.
    apitools_exceptions.HttpError: Another miscellaneous error with the listing
        service.

  Returns:
    True if the service is enabled, false otherwise.
  """
    service = serviceusage.GetService(project_id, service_name)
    return serviceusage.IsServiceEnabled(service)