1+ import base64
12import json
23import unittest
34import datetime as dt
78
89
910class IdentityMapUnitTests (unittest .TestCase ):
10- UID2_SECRET_KEY = "wJ0hP19QU4hmpB64Y3fV2dAed8t/mupw3sjN5jNRFzg="
11+ UID2_SECRET_KEY = base64 . b64encode ( b"UID2_CLIENT_SECRET" ). decode ()
1112 identity_map_client = IdentityMapClient ("UID2_BASE_URL" , "UID2_API_KEY" , UID2_SECRET_KEY )
1213
1314 def test_identity_buckets_invalid_timestamp (self ):
@@ -37,8 +38,7 @@ def test_get_datetime_utc_iso_format_timestamp(self):
3738 @patch ('uid2_client.identity_map_client.post' )
3839 @patch ('uid2_client.identity_map_client.parse_v2_response' )
3940 def test_identity_buckets_request (self , mock_parse_v2_response , mock_post , mock_make_v2_request ):
40- expected_timestamp = "2024-07-02T14:30:15.123456+00:00"
41- expected_req = json .dumps ({"since_timestamp" : get_datetime_utc_iso_format (dt .datetime .fromisoformat (expected_timestamp ))}).encode ()
41+ expected_req = b'{"since_timestamp": "2024-07-02T14:30:15.123456"}'
4242 test_cases = ["2024-07-02T14:30:15.123456+00:00" , "2024-07-02 09:30:15.123456-05:00" ,
4343 "2024-07-02T08:30:15.123456-06:00" , "2024-07-02T10:30:15.123456-04:00" ,
4444 "2024-07-02T06:30:15.123456-08:00" , "2024-07-02T23:30:15.123456+09:00" ,
@@ -50,7 +50,6 @@ def test_identity_buckets_request(self, mock_parse_v2_response, mock_post, mock_
5050 mock_response .read .return_value = b'{"mocked": "response"}'
5151 mock_post .return_value = mock_response
5252 mock_parse_v2_response .return_value = b'{"body":[],"status":"success"}'
53- print (expected_req )
5453 for timestamp in test_cases :
5554 self .identity_map_client .get_identity_buckets (dt .datetime .fromisoformat (timestamp ))
5655 called_args , called_kwargs = mock_make_v2_request .call_args
0 commit comments