Coverage for tests\request\test_request_chain.py: 100%
20 statements
« prev ^ index » next coverage.py v7.3.4, created at 2023-12-20 14:17 -0500
« prev ^ index » next coverage.py v7.3.4, created at 2023-12-20 14:17 -0500
1import unittest
2from unittest import mock
3import httpx
5from zapy.test import AssertTestResultMixin
6from zapy.utils import module
7from pathlib import Path
10class TestScript(unittest.IsolatedAsyncioTestCase, AssertTestResultMixin):
12 @mock.patch.object(
13 httpx.AsyncClient, 'send',
14 return_value = httpx.Response(200, json={'id': 'test-id'})
15 )
16 async def test_chain_success(self, mock_request):
17 chain = await module.load_ipynb('tests/assets/chain.ipynb')
18 self.assertEqual({'id': 'test-id'}, chain.out_response)
20 @mock.patch.object(
21 httpx.AsyncClient, 'send',
22 return_value = httpx.Response(200, json={'id': 'test-id'})
23 )
24 async def test_chain_error(self, mock_request):
25 with self.assertRaises(AssertionError) as ex:
26 chain = await module.load_ipynb('tests/assets/chain_asserterror.ipynb')
28 self.assertIn("AssertionError: 'FOO' != 'will raise an error'", str(ex.exception))
30 @mock.patch.object(
31 httpx.AsyncClient, 'send',
32 return_value = httpx.Response(200, json={'id': 'test-id'})
33 )
34 async def test_chain_success_import(self, mock_request):
35 rel_path = Path('tests/assets')
36 chain = await module.load_ipynb(rel_path / 'chain_import.ipynb', variables={
37 'rel_path': rel_path
38 })