def testSuccess(self): """Test overall successful argument handling.""" targets = ['foo', 'bar'] output_dir = '/tmp/uprev_output_dir' changed = ['/ebuild-1.0-r1.ebuild', '/ebuild-1.0-r2.ebuild'] expected_type = constants.BOTH_OVERLAYS request = self._GetRequest(targets=targets, overlay_type=self._BOTH, output_dir=output_dir) uprev_patch = self.PatchObject(packages_service, 'uprev_build_targets', return_value=changed) packages_controller.Uprev(request, self.response, self.api_config) # Make sure the type is right, verify build targets after. uprev_patch.assert_called_once_with(mock.ANY, expected_type, mock.ANY, output_dir) # First argument (build targets) of the first (only) call. call_targets = uprev_patch.call_args[0][0] self.assertCountEqual(targets, [t.name for t in call_targets]) for ebuild in self.response.modified_ebuilds: self.assertIn(ebuild.path, changed) changed.remove(ebuild.path) self.assertFalse(changed)
def testMockCall(self): """Test that a mock call does not execute logic, returns mocked value.""" patch = self.PatchObject(packages_service, 'uprev_build_targets') targets = ['foo', 'bar'] request = self._GetRequest(targets=targets, overlay_type=self._BOTH) packages_controller.Uprev(request, self.response, self.mock_call_config) patch.assert_not_called() self.assertTrue(self.response.modified_ebuilds)
def testValidateOnly(self): """Sanity check that a validate only call does not execute any logic.""" patch = self.PatchObject(packages_service, 'uprev_build_targets') targets = ['foo', 'bar'] request = self._GetRequest(targets=targets, overlay_type=self._BOTH) packages_controller.Uprev(request, self.response, self.validate_only_config) patch.assert_not_called()
def testOverlayTypeNoneFails(self): """Overlay type none means nothing here and should fail.""" request = self._GetRequest(targets=['foo'], overlay_type=self._NONE) with self.assertRaises(cros_build_lib.DieSystemExit): packages_controller.Uprev(request, self.response, self.api_config)
def testNoOverlayTypeFails(self): """No overlay type provided should fail.""" request = self._GetRequest(targets=['foo']) with self.assertRaises(cros_build_lib.DieSystemExit): packages_controller.Uprev(request, self.response, self.api_config)