test(python-flask): fix the stale assertion and re-enable testControllerTestModelExampleUsesImportedName

Merged
KH
5h ago
+6-4

Re-enables PythonFlaskConnexionServerCodegenTest.testControllerTestModelExampleUsesImportedName, which was disabled in #25519 after failing on master.

Why it failed

#25426 added the test expecting query_string = [('filter', Filter()),]. Independently merged changes (#25485 / the object-typed parameter work in #25427, #25450) changed how the generated controller test renders those parameters, so the line the test looked for no longer exists. The generated code is correct; the assertion was stale.

The generated test_default_controller.py now sends each parameter in its OpenAPI wire style instead of a Python repr:

        query_string = [('name', 'name_example'),          # filter (object, form/explode)
                        ('filters', [Filter()]),            # array of Filter
                        ('filterMap', {'key': Filter()}),   # map of Filter
                        ('count', openapi_server.int()),
                        ('label', 'openapi_server.Filter()'),
                        ('status', 'open')]
        headers = {
            'X-Trace': 'id,id_example',                     # Trace (object, simple style)
        }

and the body parameter uses the sanitized name filter_ = Filter() (#25450).

What changed

The test now expects the current rendering while keeping its original purpose — model examples use the imported class name ([Filter()], {'key': Filter()}, filter_ = Filter()), never the package-qualified openapi_server.Filter()/openapi_server.Trace() (still asserted via assertFileNotContains).

Test results

  • PythonFlaskConnexionServerCodegenTest + AbstractPythonConnexionServerCodegenTest: 48 tests run, 0 failures (baseline on master without this change: 47 run, 0 failures — the disabled test simply did not execute).
  • Reproduced the failure first: re-enabling the test without the assertion fix fails on Linux with the same missing line wing328 reported on Windows (query_string = [('filter', Filter()),]).
  • ./mvnw -DskipTests verify passes (checkstyle, forbiddenapis, coverage checks all clean).

Follow-up to #25519 (requested by @wing328).


šŸ¤– Generated with Claude Code


Summary by cubic

Re-enables testControllerTestModelExampleUsesImportedName, which was disabled in #25519 because it asserted a rendering of model-typed parameters that no longer matches the generated code. Query and header model parameters are now emitted in OpenAPI wire style (form/explode pairs, simple-style values) and the body parameter is sanitized to filter_, so the test expectations are updated to the current output. The test still verifies its original purpose: model examples use the imported class name ([Filter()], {'key': Filter()}, filter_ = Filter()), never the package-qualified openapi_server.Filter()/openapi_server.Trace().