-
Notifications
You must be signed in to change notification settings - Fork 21
feat(cts): generate tests for helpers #2798
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
Merged
Merged
Changes from all commits
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
423e43b
feat(cts): generate tests for helpers
millotp c80b043
update
millotp 5c5cf8e
correct generation for csharp
millotp 975662d
fix python and add ruby
millotp 13c91da
api doc
millotp 7e46806
java helpers
millotp a233953
fix java cts
millotp 25a31c2
Merge branch 'main' into feat/helper-tests
millotp 5d24370
fix csharp
millotp 7a0ce7c
fix python
millotp 17db373
disable dart and kotlin
millotp 91753af
Merge branch 'main' into feat/helper-tests
millotp d11a765
fix python
millotp 864c9ab
php good
millotp 511d1e2
scala not kotlin
millotp fcc621e
fix js
millotp 16c666a
Merge branch 'main' into feat/helper-tests
millotp 73c71e3
Merge branch 'main' into feat/helper-tests
millotp 8712073
skip for my sanity
millotp 3b5d224
Merge branch 'main' into feat/helper-tests
millotp 1e6b0d3
revert unwanted changes
millotp e23eb86
Merge branch 'main' into feat/helper-tests
millotp 175cd8d
sort sort
millotp b9ff92c
revert js
millotp 2e0d81f
Revert "revert js"
millotp 02929e0
Merge branch 'main' into feat/helper-tests
millotp 1fe9c80
fix python again
millotp File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
from json import dumps | ||
from typing import Any, Dict | ||
from urllib.parse import urlencode | ||
|
||
PRIMITIVE_TYPES = (float, bool, bytes, str, int) | ||
|
||
|
@@ -12,21 +13,30 @@ class QueryParametersSerializer: | |
query_parameters: Dict[str, Any] = {} | ||
|
||
def parse(self, value) -> Any: | ||
if isinstance(value, dict): | ||
return dumps(value) | ||
elif isinstance(value, list): | ||
if isinstance(value, list): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. does list validates dict? that's why you changed the order? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same thing as for js, we never want to stringify a dict |
||
return ",".join([self.parse(item) for item in value]) | ||
elif isinstance(value, dict): | ||
return dumps(value) | ||
elif isinstance(value, bool): | ||
return "true" if value else "false" | ||
else: | ||
return str(value) | ||
|
||
def encoded(self) -> str: | ||
return urlencode( | ||
dict(sorted(self.query_parameters.items(), key=lambda val: val[0])) | ||
).replace("+", "%20") | ||
|
||
def __init__(self, query_parameters: Dict[str, Any]) -> None: | ||
self.query_parameters = {} | ||
if query_parameters is None: | ||
return | ||
for key, value in query_parameters.items(): | ||
self.query_parameters[key] = self.parse(value) | ||
if isinstance(value, dict): | ||
for dkey, dvalue in value.items(): | ||
self.query_parameters[dkey] = self.parse(dvalue) | ||
else: | ||
self.query_parameters[key] = self.parse(value) | ||
|
||
|
||
def bodySerializer(obj: Any) -> dict: | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel like this will break something
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it did break something, it wasn't working before with generateSecuredApiKey, but you agree with me that never ever do we have a query param that looks like a serialezed object right ? we only allow primitives and array to stringified
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup but IIRC this implem was exactly the same as the legacy client but since I never found the reason why it had an object case :/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
okay but we don't have any tests that expect that, and we don't have the same behavior in other languages, this was an outlier
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can revert this if you want, but I think this is more correct
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I also think so but since it worked like that for years I think there's an edge case we are not aware of :/ we can leave it and see if there's complains
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
reverted in b9ff92c
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah bah it breaks the test because now it adds brackets to stringified array, thats why I had to put the
.join(',')
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mostly wonder how it could've been wrong for 4 years in the current JS client, maybe the engine supports this format?
Your initial solution is indeed correct to me, we can go with it and if user complain we fix it (we can also for example try it on the Crawler migration PoC too)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sounds good, the PR should be fine then