def test_get_network_status_when_unavailable(self, get_info_mock): """ Exercises the get_network_status() method. """ get_info_mock.side_effect = InvalidArguments(None, 'GETINFO request contained unrecognized keywords: ns/id/5AC9C5AA75BA1F18D8459B326B4B8111A856D290') exc_msg = "Tor was unable to provide the descriptor for '5AC9C5AA75BA1F18D8459B326B4B8111A856D290'" self.assertRaisesRegexp(DescriptorUnavailable, exc_msg, self.controller.get_network_status, '5AC9C5AA75BA1F18D8459B326B4B8111A856D290')
def test_get_network_status_when_raising_descriptor_unavailable(self, get_info_mock): """ Exercises the get_network_status() method. """ get_info_mock.side_effect = InvalidArguments(None, 'GETINFO request contained unrecognized keywords: ns/id/5AC9C5AA75BA1F18D8459B326B4B8111A856D290') try: self.controller.get_network_status('5AC9C5AA75BA1F18D8459B326B4B8111A856D290') self.fail("We should've raised an exception") except DescriptorUnavailable as exc: self.assertEqual("Tor was unable to provide the descriptor for '5AC9C5AA75BA1F18D8459B326B4B8111A856D290'", str(exc))