Skip to content

test: add utils acceptance scenarios#578

Draft
marandaneto wants to merge 1 commit into
chore/add-utils-crap-score-checkfrom
chore/add-utils-acceptance-tests
Draft

test: add utils acceptance scenarios#578
marandaneto wants to merge 1 commit into
chore/add-utils-crap-score-checkfrom
chore/add-utils-acceptance-tests

Conversation

@marandaneto
Copy link
Copy Markdown
Member

@marandaneto marandaneto commented May 15, 2026

💡 Motivation and Context

follow up #577

Add pytest-bdd acceptance coverage for posthog/utils.py on top of the CRAP-score work. These scenarios document end-to-end utility behavior in Gherkin while still running through the existing pytest CI job.

💚 How did you test it?

  • uv run --extra test pytest posthog/test/test_utils_acceptance.py --timeout=30 -q
  • uv run --extra test pytest --timeout=30 -q
  • uvx ruff check posthog/test/test_utils_acceptance.py pyproject.toml

📝 Checklist

  • I reviewed the submitted code.
  • I added tests to verify the changes.
  • I updated the docs if needed.
  • No breaking change or entry added to the changelog.

If releasing new changes

  • Ran sampo add to generate a changeset file

@socket-security
Copy link
Copy Markdown

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Addedpytest-bdd@​8.1.0100100100100100

View full report

@github-actions
Copy link
Copy Markdown
Contributor

posthog-python Compliance Report

Date: 2026-05-16 01:14:13 UTC
Duration: 4673918ms

⚠️ Some Tests Failed

29/45 tests passed, 16 failed


Capture Tests

29/29 tests passed

View Details
Test Status Duration
Format Validation.Event Has Required Fields 515ms
Format Validation.Event Has Uuid 1507ms
Format Validation.Event Has Lib Properties 1506ms
Format Validation.Distinct Id Is String 1506ms
Format Validation.Token Is Present 1507ms
Format Validation.Custom Properties Preserved 1506ms
Format Validation.Event Has Timestamp 1507ms
Retry Behavior.Retries On 503 9517ms
Retry Behavior.Does Not Retry On 400 3504ms
Retry Behavior.Does Not Retry On 401 3509ms
Retry Behavior.Respects Retry After Header 9510ms
Retry Behavior.Implements Backoff 23517ms
Retry Behavior.Retries On 500 7018ms
Retry Behavior.Retries On 502 7512ms
Retry Behavior.Retries On 504 7512ms
Retry Behavior.Max Retries Respected 23526ms
Deduplication.Generates Unique Uuids 1499ms
Deduplication.Preserves Uuid On Retry 7515ms
Deduplication.Preserves Uuid And Timestamp On Retry 14512ms
Deduplication.Preserves Uuid And Timestamp On Batch Retry 7516ms
Deduplication.No Duplicate Events In Batch 1503ms
Deduplication.Different Events Have Different Uuids 1507ms
Compression.Sends Gzip When Enabled 1506ms
Batch Format.Uses Proper Batch Structure 1506ms
Batch Format.Flush With No Events Sends Nothing 1005ms
Batch Format.Multiple Events Batched Together 1505ms
Error Handling.Does Not Retry On 403 3509ms
Error Handling.Does Not Retry On 413 3507ms
Error Handling.Retries On 408 7512ms

Feature_Flags Tests

⚠️ 0/16 tests passed, 16 failed

View Details
Test Status Duration
Request Payload.Request With Person Properties Device Id 506ms
Request Payload.Flags Request Uses V2 Query Param 300400ms
Request Payload.Flags Request Hits Flags Path Not Decide 300944ms
Request Payload.Flags Request Omits Authorization Header 301022ms
Request Payload.Token In Flags Body Matches Init 301010ms
Request Payload.Groups Round Trip 300987ms
Request Payload.Groups Default To Empty Object 300997ms
Request Payload.Person Properties Distinct Id Auto Populated When Caller Omits It 301069ms
Request Payload.Disable Geoip False Propagates As Geoip Disable False 300961ms
Request Payload.Disable Geoip Omitted Defaults To False 301030ms
Request Payload.Flag Keys To Evaluate Contains Only Requested Key 301014ms
Request Lifecycle.No Flags Request On Init Alone 300951ms
Request Lifecycle.No Flags Request On Normal Capture 301052ms
Request Lifecycle.Two Flag Calls Produce Two Remote Requests 300963ms
Request Lifecycle.Mock Response Value Is Returned To Caller 301002ms
Side Effect Events.Get Feature Flag Captures Feature Flag Called Event 301014ms

Failures

request_payload.request_with_person_properties_device_id

Field 'token' not found in /flags request body at path 'token'. Available keys: ['distinct_id', 'groups', 'person_properties', 'group_properties', 'geoip_disable', 'device_id', 'flag_keys_to_evaluate', 'sentAt', 'api_key']

request_payload.flags_request_uses_v2_query_param

No error message

request_payload.flags_request_hits_flags_path_not_decide

No error message

request_payload.flags_request_omits_authorization_header

No error message

request_payload.token_in_flags_body_matches_init

No error message

request_payload.groups_round_trip

No error message

request_payload.groups_default_to_empty_object

No error message

request_payload.person_properties_distinct_id_auto_populated_when_caller_omits_it

No error message

request_payload.disable_geoip_false_propagates_as_geoip_disable_false

No error message

request_payload.disable_geoip_omitted_defaults_to_false

No error message

request_payload.flag_keys_to_evaluate_contains_only_requested_key

No error message

request_lifecycle.no_flags_request_on_init_alone

No error message

request_lifecycle.no_flags_request_on_normal_capture

No error message

request_lifecycle.two_flag_calls_produce_two_remote_requests

No error message

request_lifecycle.mock_response_value_is_returned_to_caller

No error message

side_effect_events.get_feature_flag_captures_feature_flag_called_event

No error message

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.

1 participant