@@ -48,6 +48,27 @@ def test_fetch_qualified_segments__valid_request(self):
4848 data = json .dumps (test_payload ),
4949 timeout = OdpSegmentApiConfig .REQUEST_TIMEOUT )
5050
51+ def test_fetch_qualified_segments__custom_timeout (self ):
52+ with mock .patch ('requests.post' ) as mock_request_post :
53+ api = OdpSegmentApiManager (timeout = 12 )
54+ api .fetch_segments (api_key = self .api_key ,
55+ api_host = self .api_host ,
56+ user_key = self .user_key ,
57+ user_value = self .user_value ,
58+ segments_to_check = ["a" , "b" , "c" ])
59+
60+ test_payload = {
61+ 'query' : 'query($userId: String, $audiences: [String]) {'
62+ 'customer(vuid: $userId) '
63+ '{audiences(subset: $audiences) {edges {node {name state}}}}}' ,
64+ 'variables' : {'userId' : self .user_value , 'audiences' : ["a" , "b" , "c" ]}
65+ }
66+ request_headers = {'content-type' : 'application/json' , 'x-api-key' : self .api_key }
67+ mock_request_post .assert_called_once_with (url = self .api_host + "/v3/graphql" ,
68+ headers = request_headers ,
69+ data = json .dumps (test_payload ),
70+ timeout = 12 )
71+
5172 def test_fetch_qualified_segments__success (self ):
5273 with mock .patch ('requests.post' ) as mock_request_post :
5374 mock_request_post .return_value = \
0 commit comments