44
55import pytest
66
7- from unstructured_client import UnstructuredClient
7+ from unstructured_client import UnstructuredClient , utils
88
99FAKE_API_KEY = "91pmLBeETAbXCpNylRsLq11FdiZPTk"
1010
11+
1112@pytest .fixture (scope = "module" )
1213def platform_client (platform_api_url ) -> UnstructuredClient :
14+ # settings the retry config to always try 3 times after a fail = 4 requests sent
1315 _client = UnstructuredClient (
1416 api_key_auth = FAKE_API_KEY ,
1517 server_url = platform_api_url ,
18+ retry_config = utils .RetryConfig (
19+ "backoff" , utils .BackoffStrategy (
20+ initial_interval = 3000 ,
21+ max_interval = 3000 ,
22+ exponent = 1.0 ,
23+ max_elapsed_time = 8000
24+ ),
25+ retry_connection_errors = True
26+ )
1627 )
1728 yield _client
1829
30+
1931@pytest .fixture (scope = "module" )
2032def serverless_client (serverless_api_url ) -> UnstructuredClient :
33+ # settings the retry config to always try 3 times after a fail = 4 requests sent
2134 _client = UnstructuredClient (
2235 api_key_auth = FAKE_API_KEY ,
23- server_url = serverless_api_url
36+ server_url = serverless_api_url ,
37+ retry_config = utils .RetryConfig (
38+ "backoff" , utils .BackoffStrategy (
39+ initial_interval = 3000 ,
40+ max_interval = 3000 ,
41+ exponent = 1.0 ,
42+ max_elapsed_time = 8000
43+ ),
44+ retry_connection_errors = True
45+ )
2446 )
2547 yield _client
2648
49+
2750@pytest .fixture (autouse = True )
2851def mock_sleep (mocker , freezer ):
2952 sleep_mock = mocker .patch ("time.sleep" )
3053 sleep_mock .side_effect = lambda seconds : freezer .tick (timedelta (seconds = seconds ))
3154 yield sleep_mock
3255
56+
3357@pytest .fixture (scope = "module" )
3458def platform_api_url ():
3559 return "https://platform.unstructuredapp.io"
3660
61+
3762@pytest .fixture (scope = "module" )
3863def serverless_api_url ():
3964 return "https://api.unstructuredapp.io"
4065
66+
4167@pytest .fixture (scope = "module" )
4268def dummy_partitioned_text ():
4369 return """[
@@ -82,8 +108,9 @@ def dummy_partitioned_text():
82108 }
83109]"""
84110
111+
85112@pytest .fixture (scope = "module" )
86113def doc_path () -> Path :
87114 samples_path = Path (__file__ ).resolve ().parents [1 ] / "_sample_docs"
88115 assert samples_path .exists ()
89- return samples_path
116+ return samples_path
0 commit comments