Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UID2-3497: Support for /identity/buckets #46

Merged
merged 10 commits into from
Jul 4, 2024

Conversation

caroline-ttd
Copy link
Contributor

No description provided.

@caroline-ttd caroline-ttd changed the title Support for /identity/buckets UID2-3497: Support for /identity/buckets Jul 2, 2024
examples/sample_get_identity_buckets.py Outdated Show resolved Hide resolved
uid2_client/input_util.py Outdated Show resolved Hide resolved
examples/sample_get_identity_buckets.py Outdated Show resolved Hide resolved
examples/sample_get_identity_buckets.py Outdated Show resolved Hide resolved
self.assertTrue(len(response.buckets) == 0)
self.assertTrue(response.is_success)

def test_identity_buckets_invalid_timestamp(self):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this would be better as a unit test.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added more test cases in test_identity_buckets_invalid_timestamp

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should move test_identity_buckets_invalid_timestamp and test_get_datetime_utc_iso_format_timestamp out of IdentityMapIntegrationTests and to a unit test class.

The other tests in this class make actual API calls to an operator.

test_identity_buckets_invalid_timestamp is testing parameter validation. It shouldn't require environment variables to be set in order to run it.

test_get_datetime_utc_iso_format_timestamp doesn't test get_identity_buckets, it tests the helper method. I think we should replace test_get_datetime_utc_iso_format_timestamp with a unit test for get_identity_buckets that validates the format of the timestamp sent in the request body.

tests/test_identity_map_client.py Outdated Show resolved Hide resolved
uid2_client/Identity_buckets_response.py Outdated Show resolved Hide resolved
uid2_client/input_util.py Outdated Show resolved Hide resolved
@@ -119,3 +121,9 @@ def normalize_and_hash_phone(phone):
if not is_phone_number_normalized(phone):
raise ValueError("phone number is not normalized: " + phone)
return get_base64_encoded_hash(phone)


def get_datetime_utc_iso_format(timestamp):
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I checked how Python's @patch and call_args work together. Creating a single simple method might be easier for this unit tests.

examples/sample_get_identity_buckets.py Outdated Show resolved Hide resolved
@@ -1,6 +1,8 @@
import hashlib
import base64

import pytz
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need this new dependency, or can we just do:

dt_utc = timestamp.astimezone(timezone.utc)

New dependencies need to be declared in pyproject.toml.

Copy link
Contributor Author

@caroline-ttd caroline-ttd Jul 4, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope, we need to remove the timezone, or it will throw an exception HTTP Error 400: Bad Request. Thank you for pointing out the need to add the new dependencies. I had previously installed pytz on my local, which is why it worked for me.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, but I'm talking about the line that converts the timestamp to UTC, not the line that removes the timezone (dt_utc_without_tz = dt_utc.replace(tzinfo=None)).

I'm talking about replacing

dt_utc = timestamp.astimezone(pytz.utc)

with

dt_utc = timestamp.astimezone(timezone.utc)

so that we don't need to add a new dependency.

self.assertTrue(len(response.buckets) == 0)
self.assertTrue(response.is_success)

def test_identity_buckets_invalid_timestamp(self):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should move test_identity_buckets_invalid_timestamp and test_get_datetime_utc_iso_format_timestamp out of IdentityMapIntegrationTests and to a unit test class.

The other tests in this class make actual API calls to an operator.

test_identity_buckets_invalid_timestamp is testing parameter validation. It shouldn't require environment variables to be set in order to run it.

test_get_datetime_utc_iso_format_timestamp doesn't test get_identity_buckets, it tests the helper method. I think we should replace test_get_datetime_utc_iso_format_timestamp with a unit test for get_identity_buckets that validates the format of the timestamp sent in the request body.

@caroline-ttd caroline-ttd merged commit c815550 into main Jul 4, 2024
3 checks passed
@caroline-ttd caroline-ttd deleted the ccm-UID2-3497-implement-identity-buckets branch July 4, 2024 06:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants