def testCreate(self):
   test_project = util.GetTestActiveProjectWithSameNameAndId()
   test_project_ref = command_lib_util.ParseProject(test_project.projectId)
   op = self.messages.Operation(
       done=True, response=operations.ToOperationResponse(test_project))
   test_project = util.GetTestActiveProjectWithSameNameAndId()
   self.mock_client.projects.Create.Expect(
       self.messages.Project(
           projectId=test_project.projectId,
           name=test_project.name,
           labels=None),
       op)
   response = projects_api.Create(test_project_ref, test_project.name)
   self.assertEqual(response, op)
Example #2
0
 def testCreateProjectFails(self):
   exception = http_error.MakeHttpError(code=403)
   test_project = util.GetTestActiveProjectWithSameNameAndId()
   self._expectCreationCall(test_project, exception=exception)
   with self.assertRaises(exceptions.HttpException):
     self.RunProjects('create', test_project.projectId)
   self.AssertOutputEquals('')
Example #3
0
 def testCreateValidProjectOutput(self):
   test_project = util.GetTestActiveProjectWithSameNameAndId()
   self._expectCreationCall(test_project)
   self._expectServiceEnableCall(test_project.projectId)
   self.RunProjects('create', test_project.projectId)
   self.AssertOutputEquals('')
   self.AssertErrEquals(
       ProjectsCreateTest._CREATE_STDERR_FMT.format(test_project.projectId))
Example #4
0
 def _prepareEmptyConfigAndExpectProjectCreation(self):
   self.StartPropertyPatch(config.Paths, 'sdk_root',
                           return_value=self.temp_path)
   prop = properties.FromString('core/project')
   self.assertEqual(prop.Get(), None)
   test_project = util.GetTestActiveProjectWithSameNameAndId()
   self._expectCreationCall(test_project)
   self._expectServiceEnableCall(test_project.projectId)
   return prop, test_project.projectId
Example #5
0
 def createValidProjectHelper(self, run):
   test_project = util.GetTestActiveProjectWithSameNameAndId()
   self._expectCreationCall(test_project)
   self._expectServiceEnableCall(test_project.projectId)
   response = run('create', test_project.projectId, '--format=disable')
   self.assertEqual(response, test_project)
   self.AssertOutputEquals('')
   self.AssertErrEquals(
       ProjectsCreateTest._CREATE_STDERR_FMT.format(test_project.projectId))
Example #6
0
 def testCreateProjectAlreadyExists(self):
   exception = http_error.MakeHttpError(code=409)
   test_project = util.GetTestActiveProjectWithSameNameAndId()
   self._expectCreationCall(test_project, exception=exception)
   regexp = (r'Project creation failed. The project ID you specified is '
             'already in use by another project. Please try an alternative '
             'ID.')
   with self.assertRaisesRegex(exceptions.HttpException, regexp):
     self.RunProjects('create', test_project.projectId)
   self.AssertOutputEquals('')