def test_sends_results_raises_podactionfail_on_signalexception(self): mock_signal = self.patch(pods, "signal") err_msg = factory.make_name("error_message") mock_signal.side_effect = SignalException(err_msg) name = (factory.make_name("name"),) system_id = factory.make_name("system_id") fake_driver = MagicMock() fake_driver.get_commissioning_data.return_value = succeed( {factory.make_name("filename"): factory.make_name("data")} ) self.patch(PodDriverRegistry, "get_item").return_value = fake_driver with ExpectedException( exceptions.PodActionFail, re.escape( f"Unable to send Pod commissioning information for {name}({system_id}): {err_msg}" ), ): yield pods.send_pod_commissioning_results( pod_type=factory.make_name("type"), context={}, pod_id=random.randint(1, 10), name=name, system_id=system_id, consumer_key=factory.make_name("consumer_key"), token_key=factory.make_name("token_key"), token_secret=factory.make_name("token_secret"), metadata_url=urlparse(factory.make_url()), )
def test_refresh_logs_error(self): signal = self.patch(refresh, 'signal') maaslog = self.patch(refresh.maaslog, 'error') error = factory.make_string() signal.side_effect = SignalException(error) self.patch_scripts_failure() system_id = factory.make_name('system_id') consumer_key = factory.make_name('consumer_key') token_key = factory.make_name('token_key') token_secret = factory.make_name('token_secret') url = factory.make_url() refresh.refresh(system_id, consumer_key, token_key, token_secret, url) self.assertThat( maaslog, MockAnyCall("Error during controller refresh: %s" % error))
def test_refresh_logs_error(self): signal = self.patch(refresh, "signal") maaslog = self.patch(refresh.maaslog, "error") error = factory.make_string() signal.side_effect = SignalException(error) info_scripts = self.create_scripts_failure() system_id = factory.make_name("system_id") consumer_key = factory.make_name("consumer_key") token_key = factory.make_name("token_key") token_secret = factory.make_name("token_secret") url = factory.make_url() with patch.dict(refresh.NODE_INFO_SCRIPTS, info_scripts, clear=True): refresh.refresh(system_id, consumer_key, token_key, token_secret, url) self.assertThat( maaslog, MockAnyCall("Error during controller refresh: %s" % error))