def test_upgrade_does_not_change_CalledProcessError_subclasses(self): error_type = factory.make_exception_type(bases=(CalledProcessError,)) error = factory.make_CalledProcessError() error.__class__ = error_type # Change the class. self.expectThat(error, Not(IsInstance(ExternalProcessError))) ExternalProcessError.upgrade(error) self.expectThat(error, Not(IsInstance(ExternalProcessError))) self.expectThat(error.__class__, Is(error_type))
def test__logs_subprocess_error(self): erc = self.patch_autospec(actions, "execute_rndc_command") erc.side_effect = factory.make_CalledProcessError() with FakeLogger("maas") as logger: self.assertFalse(actions.bind_reload()) self.assertDocTestMatches( "Reloading BIND failed (is it running?): " "Command ... returned non-zero exit status ...", logger.output)
def test_logs_subprocess_error(self): erc = self.patch_autospec(actions, "execute_rndc_command") erc.side_effect = factory.make_CalledProcessError() with FakeLogger("maas") as logger: self.assertRaises(CalledProcessError, actions.bind_reconfigure) self.assertDocTestMatches( "Reloading BIND configuration failed: " "Command ... returned non-zero exit status ...", logger.output, )
def test_upgrade_upgrades_CalledProcessError(self): error = factory.make_CalledProcessError() self.expectThat(error, Not(IsInstance(ExternalProcessError))) ExternalProcessError.upgrade(error) self.expectThat(error, IsInstance(ExternalProcessError))
def test_false_on_subprocess_error(self): erc = self.patch_autospec(actions, "execute_rndc_command") erc.side_effect = factory.make_CalledProcessError() self.assertFalse(actions.bind_reload())
def test_upgrades_subprocess_error(self): erc = self.patch_autospec(actions, "execute_rndc_command") erc.side_effect = factory.make_CalledProcessError() self.assertRaises(ExternalProcessError, actions.bind_reconfigure)