Skip to content

Conversation

@rolodato
Copy link
Contributor

@rolodato rolodato commented Mar 14, 2025

Before: https://github.com/Flagsmith/edge-proxy/actions/runs/13836209807/job/38711754837

https://github.com/Flagsmith/edge-proxy/actions/runs/13820539759/job/38664556536#step:7:200

Now:

$ rye test
Running tests for edge-proxy (/Users/rolodato/source/flagsmith/edge-proxy)
================================================================ test session starts =================================================================
platform darwin -- Python 3.12.7, pytest-8.1.1, pluggy-1.4.0 -- /Users/rolodato/source/flagsmith/edge-proxy/.venv/bin/python3
cachedir: .pytest_cache
rootdir: /Users/rolodato/source/flagsmith/edge-proxy
configfile: pyproject.toml
plugins: freezegun-0.4.2, anyio-4.3.0, asyncio-0.23.6, mock-3.14.0
asyncio: mode=Mode.STRICT
collected 29 items

tests/test_environments.py::test_refresh_makes_correct_http_call PASSED                                                                        [  3%]
tests/test_environments.py::test_refresh_does_not_update_last_updated_at_if_any_request_fails PASSED                                           [  6%]
tests/test_environments.py::test_get_environment_works_correctly PASSED                                                                        [ 10%]
tests/test_environments.py::test_get_environment_raises_for_unknown_keys PASSED                                                                [ 13%]
tests/test_environments.py::test_refresh_environment_caches_clears_endpoint_caches_if_environment_changes PASSED                               [ 17%]
tests/test_environments.py::test_get_identity_flags_response_skips_cache_for_different_identity PASSED                                         [ 20%]
tests/test_environments.py::test_get_flags_response_data_skips_filter_for_server_key PASSED                                                    [ 24%]
tests/test_environments.py::test_get_flags_response_data_filters_server_side_features_for_client_key PASSED                                    [ 27%]
tests/test_environments.py::test_get_identity_flags_response_skips_filter_for_server_key PASSED                                                [ 31%]
tests/test_mappers.py::test_map_feature_state_to_response_data__return_expected PASSED                                                         [ 34%]
tests/test_mappers.py::test_map_feature_states_to_response_data__return_expected PASSED                                                        [ 37%]
tests/test_mappers.py::test_map_traits_to_response_data__return_expected PASSED                                                                [ 41%]
tests/test_models.py::test_identity_with_traits_str PASSED                                                                                     [ 44%]
tests/test_models.py::test_identity_with_traits_hash PASSED                                                                                    [ 48%]
tests/test_server.py::test_health_check_returns_200_if_cache_was_updated_recently[/proxy/health] PASSED                                        [ 51%]
tests/test_server.py::test_health_check_returns_200_if_cache_was_updated_recently[/health] PASSED                                              [ 55%]
tests/test_server.py::test_health_check_returns_500_if_cache_was_not_updated PASSED                                                            [ 58%]
tests/test_server.py::test_health_check_returns_500_if_cache_is_stale PASSED                                                                   [ 62%]
tests/test_server.py::test_health_check_returns_200_if_cache_is_stale_and_health_check_configured_correctly PASSED                             [ 65%]
tests/test_server.py::test_get_flags PASSED                                                                                                    [ 68%]
tests/test_server.py::test_get_flags_single_feature PASSED                                                                                     [ 72%]
tests/test_server.py::test_get_flags_single_feature__server_key_only_feature__return_expected PASSED                                           [ 75%]
tests/test_server.py::test_get_flags_unknown_key PASSED                                                                                        [ 79%]
tests/test_server.py::test_post_identity_with_traits PASSED                                                                                    [ 82%]
tests/test_server.py::test_post_identity__environment_with_overrides__expected_response PASSED                                                 [ 86%]
tests/test_server.py::test_post_identity__invalid_trait_data__expected_response PASSED                                                         [ 89%]
tests/test_server.py::test_get_identities PASSED                                                                                               [ 93%]
tests/test_settings.py::test_settings_are_loaded_correctly[config_file_json0-expected_config0] PASSED                                          [ 96%]
tests/test_settings.py::test_settings_are_loaded_correctly[config_file_json1-expected_config1] PASSED                                          [100%]

================================================================== warnings summary ==================================================================
.venv/lib/python3.12/site-packages/pytest_freezegun.py:17: 58 warnings
  /Users/rolodato/source/flagsmith/edge-proxy/.venv/lib/python3.12/site-packages/pytest_freezegun.py:17: DeprecationWarning: distutils Version classes are deprecated. Use packaging.version instead.
    if LooseVersion(pytest.__version__) < LooseVersion('3.6.0'):

tests/test_mappers.py::test_map_feature_state_to_response_data__return_expected
tests/test_mappers.py::test_map_feature_states_to_response_data__return_expected
tests/test_mappers.py::test_map_feature_states_to_response_data__return_expected
tests/test_models.py::test_identity_with_traits_str
tests/test_models.py::test_identity_with_traits_hash
  /Users/rolodato/source/flagsmith/edge-proxy/.venv/lib/python3.12/site-packages/pydantic/main.py:1115: PydanticDeprecatedSince20: The `parse_obj` method is deprecated; use `model_validate` instead. Deprecated in Pydantic V2.0 to be removed in V3.0. See Pydantic V2 Migration Guide at https://errors.pydantic.dev/2.7/migration/
    warnings.warn(

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
========================================================== 29 passed, 63 warnings in 2.13s ===========================================================

@matthewelwell
Copy link
Contributor

@rolodato I've approved this, but I'd rather that we do one of the following (in order of preference):

  1. Split out the replacement of on_event into it's own PR
  2. Update the title of this PR to not be a chore. This is too big a change to be a chore.

Copy link
Member

@khvn26 khvn26 left a comment

Choose a reason for hiding this comment

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

Please remove the fastapi_utils dependency.

@rolodato rolodato changed the title chore: Fix warnings chore: Replace deprecated FastAPI on_event with lifespan event handlers Mar 17, 2025
@rolodato
Copy link
Contributor Author

rolodato commented Mar 17, 2025

Split out the replacement of on_event into it's own PR

Done - kept the on_event change in this PR, I'll add everything else in a new one.

Update the title of this PR to not be a chore. This is too big a change to be a chore.

Edit: Changed to feat

Which would you prefer to use? I still think chore is the most representative, since we're not adding features or fixing bugs, or anything else in this list:

I agree this is a relatively risky change since we're changing how the core loop works, but I think it's still a chore at the end of the day. Happy to add functional/E2E tests if we need a different way to test this.

Please remove the fastapi_utils dependency.

Done

@rolodato rolodato requested review from khvn26 and removed request for khvn26 March 17, 2025 15:07
@rolodato rolodato changed the title chore: Replace deprecated FastAPI on_event with lifespan event handlers feat: Replace deprecated FastAPI on_event with lifespan event handlers Mar 17, 2025
@rolodato rolodato requested a review from khvn26 March 17, 2025 17:19
@rolodato rolodato merged commit 3389892 into main Apr 8, 2025
2 checks passed
@rolodato rolodato deleted the chore/warnings branch April 8, 2025 14:56
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.

4 participants