blob: cfb8bfb2562feb9777de7f3319bea73f0abe6509 [file]
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"id": "af165506-cc16-485c-8875-f1ec55dd94b5",
"metadata": {},
"outputs": [],
"source": [
"!pip install burr[start]"
]
},
{
"cell_type": "code",
"execution_count": 1,
"id": "5cc77bd80999b2a2",
"metadata": {
"ExecuteTime": {
"end_time": "2024-04-01T05:29:38.960440Z",
"start_time": "2024-04-01T05:29:37.926490Z"
},
"collapsed": false,
"jupyter": {
"outputs_hidden": false
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Usage: burr-test-case create [OPTIONS]\n",
"\n",
" Create a test case from a persisted state.\n",
"\n",
" Does two things:\n",
"\n",
" 1. Pulls data specified and saves it/prints to console. 2. Prints a pytest\n",
" test case to the console for you to cut and paste.\n",
"\n",
" See examples/test-case-creation/notebook.ipynb for example usage. See\n",
" examples/test-case-creation/test_application.py for details.\n",
"\n",
"Options:\n",
" --project-name TEXT Name of the project [required]\n",
" --partition-key TEXT Partition key to look at [required]\n",
" --app-id TEXT App ID to pull from. [required]\n",
" --sequence-id TEXT Sequence ID to pull. [required]\n",
" --target-file-name TEXT What file to write the data to. Else print to\n",
" console.\n",
" --help Show this message and exit.\n"
]
}
],
"source": [
"%%sh \n",
"burr-test-case create --help"
]
},
{
"cell_type": "markdown",
"id": "944a988132d19779",
"metadata": {
"collapsed": false,
"jupyter": {
"outputs_hidden": false
}
},
"source": [
"# Create a test case\n",
"\n",
"Find the data you want to create a test case with in the UI."
]
},
{
"cell_type": "code",
"execution_count": 4,
"id": "586bcb0bdb5dde8b",
"metadata": {
"ExecuteTime": {
"end_time": "2024-04-01T06:16:19.392833Z",
"start_time": "2024-04-01T06:16:18.000721Z"
},
"collapsed": false,
"jupyter": {
"outputs_hidden": false
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Found data for action: plan_cot\n",
"\n",
"Writing data to file /tmp/test-case.json\n",
"\n",
"Add the following to your test file:\n",
"\n",
"import pytest\n",
"from burr.testing import pytest_generate_tests # noqa: F401\n",
"# TODO: import action you're testing, i.e. import plan_cot.\n",
"\n",
"@pytest.mark.file_name(\"/tmp/test-case.json\")\n",
"def test_plan_cot(input_state, expected_state):\n",
" \"\"\"Function for testing the action\"\"\"\n",
" input_state = state.State(input_state)\n",
" expected_state = state.State(expected_state)\n",
" _, output_state = plan_cot(input_state) # exercise the action\n",
" assert output_state == expected_state\n",
"\n"
]
}
],
"source": [
"%%sh\n",
"burr-test-case create \\\n",
" --project-name \"SOME_PROJECT\" \n",
" --partition-key \"SOME_KEY\" \\\n",
" --app-id \"SOME_ID\" \\\n",
" --sequence-id 0 \\\n",
" --target-file-name /tmp/test-case.json"
]
},
{
"cell_type": "markdown",
"id": "3ac9d600d0807fc8",
"metadata": {
"collapsed": false,
"jupyter": {
"outputs_hidden": false
}
},
"source": [
"# What's next?\n",
" \n",
"## See `test_application.py` for code that enables you to run the test case like this.\n",
"\n",
"## Fill in the expected state part of the JSON\n",
"The expected state part of the JSON is empty. You need to fill it in with the expected state of the application after the test case has been run. Once you've\n",
"done that, you've got your test case!\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "a727cdc01303cd39",
"metadata": {
"collapsed": false,
"jupyter": {
"outputs_hidden": false
}
},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.4"
}
},
"nbformat": 4,
"nbformat_minor": 5
}