Skip to content

chore: simplify RequestOption construction in component factory#303

Merged
Christo Grabowski (ChristoGrab) merged 6 commits into
christo/request-option-field-pathfrom
christo/debug-field-path
Jan 31, 2025
Merged

chore: simplify RequestOption construction in component factory#303
Christo Grabowski (ChristoGrab) merged 6 commits into
christo/request-option-field-pathfrom
christo/debug-field-path

Conversation

@ChristoGrab
Copy link
Copy Markdown
Collaborator

@ChristoGrab Christo Grabowski (ChristoGrab) commented Jan 30, 2025

What

Refactor components in the model_to_component factory that build child RequestOptions to leverage the re-usable _create_component_from_model method, rather than instantiating them with explicit attributes (ie, field_name). Hopefully this will reduce future tech debt if the RequestOption class is further modified moving forward.

Updates a couple tests to verify the behavior when using nested body_json injected values.

@ChristoGrab Christo Grabowski (ChristoGrab) marked this pull request as ready for review January 30, 2025 23:50
@ChristoGrab Christo Grabowski (ChristoGrab) changed the title refactor: simplify RequestOption construction in component factory chore: simplify RequestOption construction in component factory Jan 30, 2025
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM! Just a small nit

)
assert stream_slicer.end_time_option.inject_into == RequestOptionType.body_json
assert stream_slicer.end_time_option.field_name.eval({}) == "before_created_at"
assert stream_slicer.end_time_option.field_path[0].eval({}) == "before_created_at"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: The outcome could be that stream_slicer.end_time_option.field_path == ["before_created_at", "another dummy parameter that we don't expect"]. Should we change this to assert stream_slicer.end_time_option.field_path == ["before_created_at"]`?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Agreed, updated the test assertion

@github-actions github-actions Bot added the chore label Jan 31, 2025
@ChristoGrab Christo Grabowski (ChristoGrab) merged commit 24264a0 into christo/request-option-field-path Jan 31, 2025
@ChristoGrab Christo Grabowski (ChristoGrab) deleted the christo/debug-field-path branch January 31, 2025 18:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants