예제 #1
0
    async def test_request_kindtype_other_error(self, gk):
        class FooKind(Kind):
            apiVersion = 'v1'

        exc = client.ApiError(resp=MagicMock(status_code=500))

        async def gk_coro(*args, **kw):
            raise exc

        gk.side_effect = gk_coro
        resp = MagicMock(status_code=200,
                         headers={'content-type': 'application/json'})
        resp.json.return_value = {
            'apiVersion': 'v1',
            'kind': 'FooKind',
            'spec': 'foospec'
        }

        async def req_coro(*args, **kw):
            return resp

        self.api.session.request.side_effect = req_coro
        with self.assertRaises(client.ApiError) as err:
            await self.api.request('GET', '/')
        self.assertIs(err.exception, exc)
예제 #2
0
    async def test_wait_until_healthy(self, sleep):
        sleep.side_effect = dummy_coro
        responses = [client.ApiError(), 'ok']

        async def get_coro(path):
            return responses.pop(0)

        self.api.get = MagicMock(side_effect=get_coro)
        await self.api.wait_until_healthy()
        self.assertEqual(responses, [])
        sleep.assert_called_once_with(client.ApiClient._health_check_interval)
        self.assertTrue(self.api.healthy.is_set())
예제 #3
0
 async def conflict_coro(*args, **kw):
     raise client.ApiError(MagicMock(status_code=500))
예제 #4
0
 async def get_coro(path):
     raise client.ApiError()
예제 #5
0
 async def get_coro(*args, **kw):
     raise client.ApiError(MagicMock(status_code=404))