@@ -31,10 +31,11 @@ If you have cloned the Feldera repo, you can install the python SDK as follows:
3131pip install python/
3232```
3333
34- Checkout the docs [ here] ( ./feldera/__init__.py ) for an example on how to use the SDK.
35-
3634## Documentation
3735
36+ The Python SDK documentation is available at
37+ [ Feldera Python SDK Docs] ( https://docs.feldera.com/python ) .
38+
3839To build the html documentation run:
3940
4041Ensure that you have sphinx installed. If not, install it using ` pip install sphinx ` .
@@ -54,34 +55,62 @@ To clean the build, run `make clean`.
5455To run unit tests:
5556
5657``` bash
57- ( cd python && python3 -m unittest)
58+ cd python && python3 -m pytest tests/
5859```
5960
60- > ⚠️ Running the unit tests will ** delete all existing pipelines** .
61-
62- The following command runs end-to-end tests. You'll need a pipeline
63- manager running at ` http://localhost:8080 ` . For the pipeline builder
64- tests, you'll also need a broker available at ` localhost:9092 ` and
65- (from the pipelines) ` redpanda:19092 ` . (To change those locations,
66- set the environment variables listed in ` python/tests/__init__.py ` .)
67-
68- ``` bash
69- (cd python && python3 -m pytest tests)
70- ```
61+ - This will detect and run all test files that match the pattern ` test_*.py ` or
62+ ` *_test.py ` .
63+ - By default, the tests expect a running Feldera instance at ` http://localhost:8080 ` .
64+ To override the default endpoint, set the ` FELDERA_BASE_URL ` environment variable.
7165
7266To run tests from a specific file:
7367
7468``` bash
75- (cd python && python3 -m unittest ./tests/path-to-file.py)
69+ (cd python && python3 -m pytest ./tests/path-to-file.py)
7670```
7771
72+ #### Running Aggregate Tests
73+
74+ The aggregate tests validate end-to-end correctness of SQL functionality.
7875To run the aggregate tests use:
7976
8077``` bash
8178cd python
8279PYTHONPATH=` pwd` python3 ./tests/aggregate_tests/main.py
8380```
8481
82+ ### Reducing Compilation Cycles
83+
84+ To reduce redundant compilation cycles during testing:
85+
86+ * ** Inherit from ` SharedTestPipeline ` ** instead of ` unittest.TestCase ` .
87+ * ** Define DDLs** (e.g., ` CREATE TABLE ` , ` CREATE VIEW ` ) in the ** docstring** of each test method.
88+ * All DDLs from all test functions in the class are combined and compiled into a single pipeline.
89+ * If a table or view is already defined in one test, it can be used directly in others without redefinition.
90+ * Ensure that all table and view names are unique within the class.
91+ * Use ` @enterprise_only ` on tests that require Enterprise features. Their DDLs will be skipped on OSS builds.
92+ * Use ` self.set_runtime_config(...) ` to override the default pipeline config.
93+ * Reset it at the end using ` self.reset_runtime_config() ` .
94+ * Access the shared pipeline via ` self.pipeline ` .
95+
96+ #### Example
97+
98+ ``` python
99+ from tests.shared_test_pipeline import SharedTestPipeline
100+
101+ class TestAverage (SharedTestPipeline ):
102+ def test_average (self ):
103+ """
104+ CREATE TABLE students(id INT, name STRING);
105+ CREATE MATERIALIZED VIEW v AS SELECT * FROM students;
106+ """
107+ ...
108+ self .pipeline.start()
109+ self .pipeline.input_pandas(" students" , df)
110+ self .pipeline.wait_for_completion(True )
111+ ...
112+ ```
113+
85114## Linting and formatting
86115
87116Use [ Ruff] to run the lint checks that will be executed by the
0 commit comments