def testValidateOnly(self): """Sanity check that a validate only call does not execute any logic.""" patch = self.PatchObject(sdk_service, 'Create') sdk_controller.Create(self._GetRequest(), self.response, self.validate_only_config) patch.assert_not_called()
def testSuccess(self): """Test the successful call output handling.""" self.PatchObject(sdk_service, 'Create', return_value=1) request = self._GetRequest() sdk_controller.Create(request, self.response, self.api_config) self.assertEqual(1, self.response.version.version)
def testMockCall(self): """Sanity check that a mock call does not execute any logic.""" patch = self.PatchObject(sdk_service, 'Create') rc = sdk_controller.Create(self._GetRequest(), self.response, self.mock_call_config) patch.assert_not_called() self.assertFalse(rc) self.assertTrue(self.response.version.version)
def testPathArguments(self): """Test the path arguments handling.""" # Create the patches. self.PatchObject(sdk_service, 'Create', return_value=1) paths_patch = self.PatchObject(sdk_service, 'ChrootPaths') # Test the path arguments get passed through. cache_dir = '/cache/dir' chroot_path = '/chroot/path' request = self._GetRequest(cache_path=cache_dir, chroot_path=chroot_path) sdk_controller.Create(request, self.response, self.api_config) paths_patch.assert_called_with(cache_dir=cache_dir, chroot_path=chroot_path)
def testTrueArguments(self): """Test True arguments handling.""" # Create the patches. self.PatchObject(sdk_service, 'Create', return_value=1) args_patch = self.PatchObject(sdk_service, 'CreateArguments') # Test all True values in the message. request = self._GetRequest(no_replace=True, bootstrap=True, no_use_image=True) sdk_controller.Create(request, self.response, self.api_config) args_patch.assert_called_with(replace=False, bootstrap=True, use_image=False, paths=mock.ANY)
def testFalseArguments(self): """Test False argument handling.""" # Create the patches. self.PatchObject(sdk_service, 'Create', return_value=1) args_patch = self.PatchObject(sdk_service, 'CreateArguments') # Flag translation tests. # Test all false values in the message. request = self._GetRequest(no_replace=False, bootstrap=False, no_use_image=False) sdk_controller.Create(request, self.response, self.api_config) args_patch.assert_called_with( replace=True, bootstrap=False, use_image=True, chroot_path=mock.ANY, cache_dir=mock.ANY)