def setup(self) -> None: url = 'http://127.0.0.1:2379/v2' if not self.context.mock_aiohttp(): url = self.context.host _ = unittest.mock.patch.object(AsyncEtcdClient, '_request', unittest.mock.MagicMock()) self.mocked_request = _.start() self.context.addCleanup(_.stop) self.client = AsyncEtcdClient(url, retries = 0)
class AsyncEtcdClientGetFixture(fixtures.Fixture): @property def description(self) -> str: return super().description + '.AsyncEtcdClient.get(**{0.parameters[kwargs]})'.format(self) def setup(self) -> None: url = 'http://127.0.0.1:2379/v2' if not self.context.mock_aiohttp(): url = self.context.host _ = unittest.mock.patch.object(AsyncEtcdClient, '_request', unittest.mock.MagicMock()) self.mocked_request = _.start() self.context.addCleanup(_.stop) self.client = AsyncEtcdClient(url, retries = 0) def run(self) -> None: self.context.loop.run_until_complete(self.client.get(**self.parameters['kwargs'])) def check(self) -> None: self.mocked_request.assert_called_once_with(method = 'GET', **self.expected)