示例#1
0
  def test_admin_api_get(self):
    """Test the get API method for the App Engine Admin API."""
    mock_client = mock.Mock()
    mock_get = mock_client.apps.return_value.get
    mock_get.return_value.execute.return_value = _FAKE_APPLICATION_OBJECT

    test_app_engine_admin_api = app_engine.AdminAPI(self.config, mock_client)
    self.assertEqual(_FAKE_APPLICATION_OBJECT, test_app_engine_admin_api.get())
示例#2
0
 def test_admin_api_get__not_found_error(self):
   """Test the get API method for an invalid project."""
   test_app_engine_admin_api = app_engine.AdminAPI(self.config, mock.Mock())
   test_app_engine_admin_api._client.apps.side_effect = errors.HttpError(
       httplib2.Response({
           'reason': 'Not found.', 'status': httplib.NOT_FOUND}),
       'App not found.')
   with self.assertRaises(app_engine.NotFoundError):
     test_app_engine_admin_api.get()
示例#3
0
 def test_admin_api_create__creation_error(self):
   """Test the App Engine project creation for an invalid project."""
   test_app_engine_admin_api = app_engine.AdminAPI(self.config, mock.Mock())
   test_app_engine_admin_api._client.apps.side_effect = errors.HttpError(
       httplib2.Response({
           'reason': 'Not found.', 'status': httplib.NOT_FOUND}),
       'Project not found.')
   with self.assertRaises(app_engine.CreationError):
     test_app_engine_admin_api.create('us-east1')
示例#4
0
  def test_admin_api_create(self):
    """Test the create API method for the App Engine Admin API."""
    mock_client = mock.Mock()
    mock_create = mock_client.apps.return_value.create
    mock_create.return_value.execute.return_value = _FAKE_APPLICATION_OBJECT

    test_app_engine_admin_api = app_engine.AdminAPI(self.config, mock_client)
    self.assertEqual(
        _FAKE_APPLICATION_OBJECT, test_app_engine_admin_api.create('us-east1'))
示例#5
0
 def test_admin_api_create__not_found_error(self):
   """Test the App Engine project creation for an invalid location."""
   test_app_engine_admin_api = app_engine.AdminAPI(self.config, mock.Mock())
   with self.assertRaises(app_engine.NotFoundError):
     test_app_engine_admin_api.create('INVALID_LOCATION')