Conversation
0528146 to
ebc8868
Compare
|
Are you make these test run automatically with the existing tests? |
@abnegate I don't think we can do that yet. But we want to use these test to run in the |
|
@abnegate let's get this merged in a different branch and sync |
|
Quick triage check: is this PR still active? It has been inactive for a long time and there is newer testing work in the repo now. If you still plan to continue, please share status/rebase plan; otherwise we can close it for now. |
ebc8868 to
864a059
Compare
Greptile SummaryThis PR adds generated unit tests to the Python SDK, covering The individual test templates are well-written and cover a good breadth of the SDK surface area. However, there are two bugs in the
Confidence Score: 4/5Two P1 bugs in the PHP code-generation logic must be fixed before service tests will work correctly for all API models. The test templates themselves are sound and the CI integration is straightforward, but the
Important Files Changed
Reviews (1): Last reviewed commit: "WIP fix: tests" | Re-trigger Greptile |
| if ($property['type'] === 'object') { | ||
| echo $property; | ||
| return ''; | ||
| } | ||
|
|
||
| $result[$property['name']] = match ($property['type']) { | ||
| 'object' => $this->getResponseModelExample($property['sub_schema'], $spec), |
There was a problem hiding this comment.
Debug
echo statement and dead 'object' match arm
Lines 764–767 contain a debug echo $property (calling echo on a PHP array triggers a "Array to string conversion" notice and literally outputs the string "Array" to stdout) followed by return ''. Because this early-return guard fires for every property whose type is 'object', the 'object' arm in the match expression on line 770 can never execute — it is dead code.
The intent of the function is clearly to recurse into nested response models for object-typed properties, but the debug block prevents that. The correct fix is to remove the dead guard block entirely so the match handles it:
$result[$property['name']] = match ($property['type']) {
'object' => $this->getResponseModelExample($property['sub_schema'], $spec),
'array' => [],
'string' => $property['example'] ?? '',
'boolean' => true,
default => $property['example'],
};|
|
||
| $json = json_encode($result, JSON_PRETTY_PRINT); | ||
|
|
||
| return str_replace('true', "True", $json); |
There was a problem hiding this comment.
Missing
false→False and null→None replacements
Only true is replaced with its Python equivalent True. JSON also uses false and null, which are invalid Python literals — Python expects False and None respectively. If any property's example value in the spec resolves to PHP false or PHP null (serialised via the default branch of the match), the generated .py test file will contain a syntax error.
$json = json_encode($result, JSON_PRETTY_PRINT);
return str_replace(
['true', 'false', 'null'],
['True', 'False', 'None'],
$json
);| @@ -1,2 +1,3 @@ | |||
| requests>=2.31,<3 | |||
| requests_mock==1.11.0 | |||
There was a problem hiding this comment.
Exact version pin inconsistent with other dependencies
requests_mock is pinned to exactly 1.11.0 with ==, while requests and pydantic both use flexible ranges (e.g. >=2.31,<3). An exact pin means the package won't automatically receive patch-level bug fixes and may cause resolution conflicts in environments that already have a different requests_mock version installed. Consider aligning with the project's convention:
requests_mock>=1.11,<2
What does this PR do?
This PR adds generated unit tests to the Python SDK.
Test Plan
Generate the SDK, weave hands to get the dependencies installed (my IDE did it for me, I have no clue about Python, I am sorry!), then run
python3 -m unittest.Related PRs and Issues
#680
Have you read the Contributing Guidelines on issues?
Yup
Discord username for swag as requested by Tessa: yestheory