Menu
Introduction
Getting Started
Developer guide
Release
Architecture
CLI
Technical documentations
Version
Publication date

Mar 9, 2022

Reactions
2
Share

AppTester

Helper class to test that an app (Reflex or Streamlit) starts and runs correctly.

Usage with a task that generates the app: AppTester.test_app_from_task( test_case=self, generate_task_type=GenerateReflexShowcaseApp, app_output_name="reflex_app", input_resources={"resource": table}, )

Usage with an existing AppResource: AppTester.test_app(self, app_resource)

For a much faster, Reflex-only check that the app builds (no process start, no health check, no database), use test_app_compiles / test_app_compiles_from_task instead.

Functions
test_app @staticmethod

Test that an app resource starts and runs correctly.

test_case : TestCase
The unittest.TestCase instance (used for assertions).
app_resource : AppResource
test_app_compiles @staticmethod

Check that a Reflex AppResource compiles, without starting it.

test_case : TestCase
The unittest.TestCase instance (used for assertions).
app_resource : AppResource
test_app_compiles_from_task @staticmethod

Run a task to generate a Reflex AppResource, then check that it compiles.

This is a much faster alternative to test_app_from_task: it only checks that the app builds (imports, pages, computed vars), without starting a process, opening a port, or hitting a health check. It needs no database and does not verify that the app behaves correctly with real data. Streamlit apps have no compile step, so this only supports Reflex apps.

test_case : TestCase
The unittest.TestCase instance (used for assertions).
generate_task_type : type
The task class that generates the AppResource.
app_output_name : str
The name of the task output port that produces the AppResource.
input_resources : dict[str, gws_core.resource.resource.Resource] | None
Optional dict mapping input port names to resources. Resources will be saved as ResourceModels and connected as sources.
config_values : dict | None
test_app_from_task @staticmethod

Run a task to generate an AppResource, then test that the app starts and runs correctly. It tests that the resource generated by the generate_task_type can be started as an app, that the app process is running, and that the health check endpoint returns a successful response. It also tests that the app process can be stopped.

test_case : TestCase
The unittest.TestCase instance (used for assertions).
generate_task_type : type
The task class that generates the AppResource.
app_output_name : str
The name of the task output port that produces the AppResource.
input_resources : dict[str, gws_core.resource.resource.Resource] | None
Optional dict mapping input port names to resources. Resources will be saved as ResourceModels and connected as sources.
config_values : dict | None
test_app_from_task_runner @staticmethod

Run a task using TaskRunner to generate an AppResource, then test that the app starts and runs correctly. This is a lighter alternative to test_app_from_task that does not require creating a full scenario.

test_case : TestCase
The unittest.TestCase instance (used for assertions).
generate_task_type : type
The task class that generates the AppResource.
app_output_name : str
The name of the task output port that produces the AppResource.
input_resources : dict[str, gws_core.resource.resource.Resource] | None
Optional dict mapping input port names to resources.
config_values : dict | None
Shine Logo
Technical bricks to reuse or customize

Have you developed a brick?

Share it to accelerate projects for the entire community.