Beispiel #1
0
 def unsupported_payload_unregister_test(self, get_proxy, run_task,
                                         switch_source):
     """Test that unregister() survives unsupported payload."""
     payload = Mock()
     payload.type = PAYLOAD_TYPE_RPM_OSTREE
     progress_callback = Mock()
     error_callback = Mock()
     subscription_proxy = get_proxy.return_value
     # simulate the system being registered,
     subscription_proxy.IsRegistered = True
     # run the function
     unregister(payload=payload,
                overridden_source_type=SOURCE_TYPE_CDROM,
                progress_callback=progress_callback,
                error_callback=error_callback)
     # there should be the unregistration & done phases
     progress_callback.assert_has_calls(
         [call(SubscriptionPhase.UNREGISTER),
          call(SubscriptionPhase.DONE)])
     # the error callback should not have been called
     error_callback.assert_not_called()
     # we should have requested the appropriate tasks
     subscription_proxy.SetRHSMConfigWithTask.assert_called_once()
     subscription_proxy.UnregisterWithTask.assert_called_once()
     # and tried to run them
     run_task.assert_called()
     # but we should have not tried to switch source as this
     # payload is not supported
     switch_source.assert_not_called()
Beispiel #2
0
 def unregister_back_to_cdrom_test(self, get_proxy, run_task,
                                   switch_source):
     """Test the unregister() helper method - roll back to CDROM source."""
     payload = Mock()
     payload.type = PAYLOAD_TYPE_DNF
     source_proxy = payload.get_source_proxy.return_value
     source_proxy.Type = SOURCE_TYPE_CDN
     progress_callback = Mock()
     error_callback = Mock()
     subscription_proxy = get_proxy.return_value
     # simulate the system being registered,
     subscription_proxy.IsRegistered = True
     # run the function
     unregister(payload=payload,
                overridden_source_type=SOURCE_TYPE_CDROM,
                progress_callback=progress_callback,
                error_callback=error_callback)
     # there should be the unregistration & done phases
     progress_callback.assert_has_calls(
         [call(SubscriptionPhase.UNREGISTER),
          call(SubscriptionPhase.DONE)])
     # the error callback should not have been called
     error_callback.assert_not_called()
     # we should have requested the appropriate tasks
     subscription_proxy.SetRHSMConfigWithTask.assert_called_once()
     subscription_proxy.UnregisterWithTask.assert_called_once()
     # and tried to run them
     run_task.assert_called()
     # also we should have tried switching back to the CDROM source
     switch_source.assert_called_once_with(payload, SOURCE_TYPE_CDROM)
Beispiel #3
0
 def unregister_failed_test(self, get_proxy, run_task):
     """Test the unregister() helper method - unregistration failed."""
     payload = Mock()
     progress_callback = Mock()
     error_callback = Mock()
     subscription_proxy = get_proxy.return_value
     # simulate the system being registered,
     subscription_proxy.IsRegistered = True
     # make the unregistration task fail
     run_task.side_effect = [
         True, UnregistrationError("unregistration failed")
     ]
     # run the function
     unregister(payload=payload,
                overridden_source_type=None,
                progress_callback=progress_callback,
                error_callback=error_callback)
     # there should be only the unregistration phase
     progress_callback.assert_has_calls(
         [call(SubscriptionPhase.UNREGISTER)])
     # and the error callback should have been triggered
     error_callback.assert_called_once_with("unregistration failed")
     # we should have requested the appropriate tasks
     subscription_proxy.SetRHSMConfigWithTask.assert_called_once()
     subscription_proxy.UnregisterWithTask.assert_called_once()
     # and tried to run them
     run_task.assert_called()
Beispiel #4
0
 def unregister_not_registered_test(self, get_proxy, run_task):
     """Test the unregister() helper method - not registered."""
     # this is effectively a no-op
     progress_callback = Mock()
     error_callback = Mock()
     subscription_proxy = get_proxy.return_value
     # simulate the system being registered,
     subscription_proxy.IsRegistered = False
     # run the function
     unregister(progress_callback=progress_callback,
                error_callback=error_callback)
     # there should be just the done phase
     progress_callback.assert_has_calls([call(SubscriptionPhase.DONE)])
     # the error callback should not have been called
     error_callback.assert_not_called()
     # no need to request and run any tasks
     run_task.assert_not_called()
Beispiel #5
0
 def unregister_test(self, get_proxy, run_task):
     """Test the unregister() helper method."""
     progress_callback = Mock()
     error_callback = Mock()
     subscription_proxy = get_proxy.return_value
     # simulate the system being registered,
     subscription_proxy.IsRegistered = True
     # run the function
     unregister(progress_callback=progress_callback,
                error_callback=error_callback)
     # there should be the unregistration & done phases
     progress_callback.assert_has_calls(
         [call(SubscriptionPhase.UNREGISTER),
          call(SubscriptionPhase.DONE)])
     # the error callback should not have been called
     error_callback.assert_not_called()
     # we should have requested the appropriate tasks
     subscription_proxy.UnregisterWithTask.assert_called_once()
     # and tried to run them
     run_task.assert_called()