22
33import pytest
44from beartype .typing import Dict , List , Union
5- from fast_bitrix24 .bitrix import BitrixAsync
65from fast_bitrix24 .logger import logger
76from fast_bitrix24 .server_response import ServerResponseParser
87from fast_bitrix24 .srh import ServerRequestHandler
98
109logger .addHandler (logging .StreamHandler ())
1110
1211
13- @pytest .fixture
14- def bitrix ():
15- return BitrixAsync ("https://google.com/path" )
16-
17-
1812class MockSRH (ServerRequestHandler ):
1913 def __init__ (self , response : Union [Dict , List [Dict ]]):
2014 self .response = response if isinstance (response , list ) else [response ]
@@ -39,43 +33,35 @@ def test_single_success():
3933 assert isinstance (results , list )
4034
4135
42- @pytest .mark .asyncio
43- async def test_batch_success (bitrix ):
44- from tests .real_responses .crm_lead_list_several_pages_success import \
45- response
36+ def test_batch_success (bx_dummy ):
37+ from tests .real_responses .crm_lead_list_several_pages_success import response
4638
47- bitrix .srh = MockSRH (response )
48- results = await bitrix .get_all ("crm.lead.list" )
39+ bx_dummy .srh = MockSRH (response )
40+ results = bx_dummy .get_all ("crm.lead.list" )
4941 assert isinstance (results , list )
5042
5143
52- @pytest .mark .asyncio
53- async def test_batch_single_page_error (bitrix ):
54- from tests .real_responses .crm_get_batch_mix_success_and_errors import \
55- response
44+ def test_batch_single_page_error (bx_dummy ):
45+ from tests .real_responses .crm_get_batch_mix_success_and_errors import response
5646
57- bitrix .srh = MockSRH (response )
47+ bx_dummy .srh = MockSRH (response )
5848 with pytest .raises (RuntimeError ):
59- await bitrix .get_by_ID ("crm.lead.get" , [0 , 1 , 35943 ])
49+ bx_dummy .get_by_ID ("crm.lead.get" , [0 , 1 , 35943 ])
6050
6151
62- @pytest .mark .asyncio
63- async def test_call_single_success (bitrix ):
52+ def test_call_single_success (bx_dummy ):
6453 from tests .real_responses .call_single_success import response
6554
66- bitrix .srh = MockSRH (response )
67- results = await bitrix .call ("crm.lead.get" , {"ID" : 35943 })
55+ bx_dummy .srh = MockSRH (response )
56+ results = bx_dummy .call ("crm.lead.get" , {"ID" : 35943 })
6857 assert isinstance (results , dict )
6958
7059
71- @pytest .mark .asyncio
72- async def test_call_several_success (bitrix ):
60+ def test_call_several_success (bx_dummy ):
7361 from tests .real_responses .call_several_success import response
7462
75- bitrix .srh = MockSRH (response )
76- results = await bitrix .call (
77- "crm.lead.get" , [{"ID" : 35943 }, {"ID" : 161 }, {"ID" : 171 }]
78- )
63+ bx_dummy .srh = MockSRH (response )
64+ results = bx_dummy .call ("crm.lead.get" , [{"ID" : 35943 }, {"ID" : 161 }, {"ID" : 171 }])
7965 assert isinstance (results , tuple )
8066 assert len (results ) == 3
8167 assert isinstance (results [0 ], dict )
0 commit comments