You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: end_to_end_tests/generated_code_live_tests/README.md
+4-5
Original file line number
Diff line number
Diff line change
@@ -5,14 +5,14 @@ These are end-to-end tests which run the code generator command, but unlike the
5
5
Each test class follows this pattern:
6
6
7
7
- Use the decorator `@with_generated_client_fixture`, providing an inline API spec (JSON or YAML) that contains whatever schemas/paths/etc. are relevant to this test class.
8
-
- The spec can omit the `openapi:`and `info:` blocks, unless those are relevant to the test.
8
+
- The spec can omit the `openapi:`, `info:`, and `paths:`, blocks, unless those are relevant to the test.
9
9
- The decorator creates a temporary file for the inline spec and a temporary directory for the generated code, and runs the client generator.
10
10
- It creates a `GeneratedClientContext` object (defined in `end_to_end_test_helpers.py`) to keep track of things like the location of the generated code and the output of the generator command.
11
11
- This object is injected into the test class as a fixture called `generated_client`, although most tests will not need to reference the fixture directly.
12
12
-`sys.path` is temporarily changed, for the scope of this test class, to allow imports from the generated code.
13
-
- Use the decorator `@with_generated_code_import` to make classes or functions from the generated code available to the tests.
14
-
-`@with_generated_code_import(".models.MyModel")` would execute `from [client package name].models import MyModel` and inject the imported object into the test class as a fixture called `MyModel`.
15
-
-`@with_generated_code_import(".models.MyModel", alias="model1")` would do the same thing, but the fixture would be named `model1`.
13
+
- Use the decorator `@with_generated_code_imports` or `@with_generated_code_import` to make classes or functions from the generated code available to the tests.
14
+
-`@with_generated_code_imports(".models.MyModel1", ".models.MyModel2)` would execute `from [package name].models import MyModel1, MyModel2` and inject the imported classes into the test class as fixtures called `MyModel1` and `MyModel2`.
15
+
-`@with_generated_code_import(".api.my_operation.sync", alias="endpoint_method")` would execute `from [package name].api.my_operation import sync`, but the fixture would be named `endpoint_method`.
16
16
- After the test class finishes, these imports are discarded.
0 commit comments