From 9eee1c839d69194475c3d296eaf97fb1cf599ff5 Mon Sep 17 00:00:00 2001 From: harishmohanraj Date: Wed, 11 Oct 2023 00:14:19 +0000 Subject: [PATCH 1/7] Add test files for examples --- pytest.ini | 5 +++++ search/tests/__init__.py | 0 search/tests/examples/__init__.py | 0 .../examples/test_example_consume_publish_with_key.py | 5 +++++ search/tests/examples/test_example_course_update.py | 6 ++++++ search/tests/examples/test_example_execute_trade.py | 6 ++++++ .../examples/test_example_forward_to_another_topic.py | 3 +++ .../examples/test_example_forward_to_multiple_topics.py | 3 +++ .../tests/examples/test_example_infinity_publishing.py | 7 +++++++ search/tests/examples/test_example_investment_updates.py | 9 +++++++++ search/tests/examples/test_example_new_employee.py | 3 +++ search/tests/examples/test_example_pets.py | 3 +++ search/tests/examples/test_example_plants.py | 6 ++++++ search/tests/examples/test_example_product_reviews.py | 9 +++++++++ search/tests/examples/test_example_publish_with_key.py | 5 +++++ search/tests/examples/test_example_scram256_security.py | 3 +++ search/tests/examples/test_example_scram512_security.py | 3 +++ search/tests/examples/test_example_scrape_weather.py | 9 +++++++++ search/tests/examples/test_example_social_media_post.py | 6 ++++++ search/tests/examples/test_example_student_query.py | 5 +++++ search/tests/examples/test_example_weather_updates.py | 6 ++++++ 21 files changed, 102 insertions(+) create mode 100644 pytest.ini create mode 100644 search/tests/__init__.py create mode 100644 search/tests/examples/__init__.py create mode 100644 search/tests/examples/test_example_consume_publish_with_key.py create mode 100644 search/tests/examples/test_example_course_update.py create mode 100644 search/tests/examples/test_example_execute_trade.py create mode 100644 search/tests/examples/test_example_forward_to_another_topic.py create mode 100644 search/tests/examples/test_example_forward_to_multiple_topics.py create mode 100644 search/tests/examples/test_example_infinity_publishing.py create mode 100644 search/tests/examples/test_example_investment_updates.py create mode 100644 search/tests/examples/test_example_new_employee.py create mode 100644 search/tests/examples/test_example_pets.py create mode 100644 search/tests/examples/test_example_plants.py create mode 100644 search/tests/examples/test_example_product_reviews.py create mode 100644 search/tests/examples/test_example_publish_with_key.py create mode 100644 search/tests/examples/test_example_scram256_security.py create mode 100644 search/tests/examples/test_example_scram512_security.py create mode 100644 search/tests/examples/test_example_scrape_weather.py create mode 100644 search/tests/examples/test_example_social_media_post.py create mode 100644 search/tests/examples/test_example_student_query.py create mode 100644 search/tests/examples/test_example_weather_updates.py diff --git a/pytest.ini b/pytest.ini new file mode 100644 index 0000000..b14c884 --- /dev/null +++ b/pytest.ini @@ -0,0 +1,5 @@ +[pytest] +minversion = 7.0 +addopts = -ra -q +testpaths = + search/tests \ No newline at end of file diff --git a/search/tests/__init__.py b/search/tests/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/search/tests/examples/__init__.py b/search/tests/examples/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/search/tests/examples/test_example_consume_publish_with_key.py b/search/tests/examples/test_example_consume_publish_with_key.py new file mode 100644 index 0000000..8a48a49 --- /dev/null +++ b/search/tests/examples/test_example_consume_publish_with_key.py @@ -0,0 +1,5 @@ +from search.examples.example_consume_publish_with_key.test_app import ( + test_point_was_incremented, +) + +__all__ = ("test_point_was_incremented",) diff --git a/search/tests/examples/test_example_course_update.py b/search/tests/examples/test_example_course_update.py new file mode 100644 index 0000000..79b37bc --- /dev/null +++ b/search/tests/examples/test_example_course_update.py @@ -0,0 +1,6 @@ +from search.examples.example_course_updates.test_app import ( + test_app_with_new_content, + test_app_without_new_content, +) + +__all__ = ("test_app_with_new_content", "test_app_without_new_content") diff --git a/search/tests/examples/test_example_execute_trade.py b/search/tests/examples/test_example_execute_trade.py new file mode 100644 index 0000000..ce8335d --- /dev/null +++ b/search/tests/examples/test_example_execute_trade.py @@ -0,0 +1,6 @@ +from search.examples.example_execute_trade.test_app import ( + test_app_with_sell_action, + test_app_without_sell_action, +) + +__all__ = ("test_app_without_sell_action", "test_app_with_sell_action") diff --git a/search/tests/examples/test_example_forward_to_another_topic.py b/search/tests/examples/test_example_forward_to_another_topic.py new file mode 100644 index 0000000..1cf65d9 --- /dev/null +++ b/search/tests/examples/test_example_forward_to_another_topic.py @@ -0,0 +1,3 @@ +from search.examples.example_forward_to_another_topic.test_app import test_app + +__all__ = ("test_app",) diff --git a/search/tests/examples/test_example_forward_to_multiple_topics.py b/search/tests/examples/test_example_forward_to_multiple_topics.py new file mode 100644 index 0000000..add9c7f --- /dev/null +++ b/search/tests/examples/test_example_forward_to_multiple_topics.py @@ -0,0 +1,3 @@ +from search.examples.example_forward_to_multiple_topics.test_app import test_app + +__all__ = ("test_app",) diff --git a/search/tests/examples/test_example_infinity_publishing.py b/search/tests/examples/test_example_infinity_publishing.py new file mode 100644 index 0000000..841d13e --- /dev/null +++ b/search/tests/examples/test_example_infinity_publishing.py @@ -0,0 +1,7 @@ +# import pytest + +from search.examples.example_infinity_publishing.test_app import ( + test_message_was_published, +) +__all__ = ("test_message_was_published",) +# pytest.mark.slow(test_message_was_published) diff --git a/search/tests/examples/test_example_investment_updates.py b/search/tests/examples/test_example_investment_updates.py new file mode 100644 index 0000000..5b0b420 --- /dev/null +++ b/search/tests/examples/test_example_investment_updates.py @@ -0,0 +1,9 @@ +from search.examples.example_investment_updates.test_app import ( + test_invest_grater_amount_than_threshold, + test_invest_smaller_amount_than_threshold, +) + +__all__ = ( + "test_invest_smaller_amount_than_threshold", + "test_invest_grater_amount_than_threshold", +) diff --git a/search/tests/examples/test_example_new_employee.py b/search/tests/examples/test_example_new_employee.py new file mode 100644 index 0000000..82fb168 --- /dev/null +++ b/search/tests/examples/test_example_new_employee.py @@ -0,0 +1,3 @@ +from search.examples.example_new_employee.test_app import test_new_employee + +__all__ = ("test_new_employee",) diff --git a/search/tests/examples/test_example_pets.py b/search/tests/examples/test_example_pets.py new file mode 100644 index 0000000..2335d38 --- /dev/null +++ b/search/tests/examples/test_example_pets.py @@ -0,0 +1,3 @@ +from search.examples.example_pets.test_app import test_app + +__all__ = ("test_app",) diff --git a/search/tests/examples/test_example_plants.py b/search/tests/examples/test_example_plants.py new file mode 100644 index 0000000..9eed75b --- /dev/null +++ b/search/tests/examples/test_example_plants.py @@ -0,0 +1,6 @@ +from search.examples.example_plants.test_app import ( + test_sell_plant_is_called, + test_still_growing_is_calles, +) + +__all__ = ("test_sell_plant_is_called", "test_still_growing_is_calles") diff --git a/search/tests/examples/test_example_product_reviews.py b/search/tests/examples/test_example_product_reviews.py new file mode 100644 index 0000000..743d272 --- /dev/null +++ b/search/tests/examples/test_example_product_reviews.py @@ -0,0 +1,9 @@ +from search.examples.example_product_reviews.test_app import ( + test_app_where_review_grade_is_grater_then_5, + test_app_where_review_grade_is_less_then_5, +) + +__all__ = ( + "test_app_where_review_grade_is_grater_then_5", + "test_app_where_review_grade_is_less_then_5", +) diff --git a/search/tests/examples/test_example_publish_with_key.py b/search/tests/examples/test_example_publish_with_key.py new file mode 100644 index 0000000..1cec9a0 --- /dev/null +++ b/search/tests/examples/test_example_publish_with_key.py @@ -0,0 +1,5 @@ +from search.examples.example_publish_with_key.test_app import ( + test_point_was_incremented, +) + +__all__ = ("test_point_was_incremented",) diff --git a/search/tests/examples/test_example_scram256_security.py b/search/tests/examples/test_example_scram256_security.py new file mode 100644 index 0000000..62f5834 --- /dev/null +++ b/search/tests/examples/test_example_scram256_security.py @@ -0,0 +1,3 @@ +from search.examples.example_scram256_security.test_app import test_app + +__all__ = ("test_app",) diff --git a/search/tests/examples/test_example_scram512_security.py b/search/tests/examples/test_example_scram512_security.py new file mode 100644 index 0000000..e7071d3 --- /dev/null +++ b/search/tests/examples/test_example_scram512_security.py @@ -0,0 +1,3 @@ +from search.examples.example_scram512_security.test_app import test_app + +__all__ = ("test_app",) diff --git a/search/tests/examples/test_example_scrape_weather.py b/search/tests/examples/test_example_scrape_weather.py new file mode 100644 index 0000000..d784aae --- /dev/null +++ b/search/tests/examples/test_example_scrape_weather.py @@ -0,0 +1,9 @@ +# import pytest + +from search.examples.example_scrape_weather.test_app import ( + test_message_was_published, +) + +__all__ = ("test_message_was_published",) + +# pytest.mark.slow(test_message_was_published) \ No newline at end of file diff --git a/search/tests/examples/test_example_social_media_post.py b/search/tests/examples/test_example_social_media_post.py new file mode 100644 index 0000000..adbc6a8 --- /dev/null +++ b/search/tests/examples/test_example_social_media_post.py @@ -0,0 +1,6 @@ +from search.examples.example_social_media_post.test_app import ( + test_post_with_just_two_likes, + test_post_with_many_likes, +) + +__all__ = ("test_post_with_just_two_likes", "test_post_with_many_likes") diff --git a/search/tests/examples/test_example_student_query.py b/search/tests/examples/test_example_student_query.py new file mode 100644 index 0000000..78ec3e7 --- /dev/null +++ b/search/tests/examples/test_example_student_query.py @@ -0,0 +1,5 @@ +from search.examples.example_student_query.test_app import ( + test_message_published_to_correct_topic, +) + +__all__ = ("test_message_published_to_correct_topic",) diff --git a/search/tests/examples/test_example_weather_updates.py b/search/tests/examples/test_example_weather_updates.py new file mode 100644 index 0000000..4f703b0 --- /dev/null +++ b/search/tests/examples/test_example_weather_updates.py @@ -0,0 +1,6 @@ +from search.examples.example_weather_updates.test_app import ( + test_not_published_to_weather_alerts, + test_published_to_weather_alerts, +) + +__all__ = ("test_not_published_to_weather_alerts", "test_published_to_weather_alerts") From 4f6054a611198858a944e61602a0fbcf10ebf380 Mon Sep 17 00:00:00 2001 From: harishmohanraj Date: Wed, 11 Oct 2023 00:19:31 +0000 Subject: [PATCH 2/7] Add CI action file to test the faststream examples --- .../workflows/test-faststream-examples.yaml | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 .github/workflows/test-faststream-examples.yaml diff --git a/.github/workflows/test-faststream-examples.yaml b/.github/workflows/test-faststream-examples.yaml new file mode 100644 index 0000000..b09e655 --- /dev/null +++ b/.github/workflows/test-faststream-examples.yaml @@ -0,0 +1,22 @@ +name: Test faststream gen examples +on: [workflow_dispatch, pull_request, push] + + +jobs: + test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v4 + with: + python-version: 3.8 + - name: Install Dependencies and library + shell: bash + run: | + set -ux + python -m pip install --upgrade pip + pip install -e ".[dev]" + - name: Run pytest + shell: bash + run: pytest + From b607019aa6a83d295b87f1a3c8ec9215d6dad92d Mon Sep 17 00:00:00 2001 From: harishmohanraj Date: Wed, 11 Oct 2023 00:33:33 +0000 Subject: [PATCH 3/7] Fix failing tests --- nbs/Helper.ipynb | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/nbs/Helper.ipynb b/nbs/Helper.ipynb index ea8aa06..1c12095 100644 --- a/nbs/Helper.ipynb +++ b/nbs/Helper.ipynb @@ -926,7 +926,7 @@ "name": "stdout", "output_type": "stream", "text": [ - "/tmp/tmp4492dn2w/grand-parent/parent/child/application.py\n", + "/tmp/tmp3i7gtvzn/grand-parent/parent/child/application.py\n", "\n", "\n", "print(\"Hello World\")\n", @@ -995,7 +995,7 @@ "name": "stdout", "output_type": "stream", "text": [ - "/tmp/tmpv8rje5w0/grand-parent/parent/child/application.py\n", + "/tmp/tmpa4z2fli7/grand-parent/parent/child/application.py\n", "\n", "\n", "print(\"Hello World\")\n", @@ -1031,7 +1031,7 @@ "name": "stdout", "output_type": "stream", "text": [ - "\n" + "\n" ] } ], @@ -1205,15 +1205,15 @@ "name": "stdout", "output_type": "stream", "text": [ - "['api', 'kafka', 'getting-started', 'index', 'release', 'nats', 'rabbit']\n" + "['README', 'faststream', '.pre-commit-config', 'CONTRIBUTING', '.github', 'CODE_OF_CONDUCT', 'pyproject', 'docs', 'scripts', 'SECURITY', 'examples', 'LICENSE', 'tests', '.gitignore', '.secrets']\n" ] } ], "source": [ "with download_and_extract_github_repo(FASTSTREAM_REPO_ZIP_URL) as extracted_path:\n", - " files = [p.stem for p in list(Path(extracted_path/FASTSTREAM_ROOT_DIR_NAME/FASTSTREAM_DOCS_DIR_SUFFIX).glob(\"*\"))]\n", + " files = [p.stem for p in list(Path(extracted_path/FASTSTREAM_ROOT_DIR_NAME).glob(\"*\"))]\n", " print(files)\n", - " assert \"index\" in files" + " assert \"pyproject\" in files" ] }, { From 1f769bb1abe738061d11eb624b34e51cbe97a38a Mon Sep 17 00:00:00 2001 From: harishmohanraj Date: Wed, 11 Oct 2023 00:42:34 +0000 Subject: [PATCH 4/7] Add test script file --- .github/workflows/test-faststream-examples.yaml | 2 +- scripts/test.sh | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) create mode 100755 scripts/test.sh diff --git a/.github/workflows/test-faststream-examples.yaml b/.github/workflows/test-faststream-examples.yaml index b09e655..6ca455e 100644 --- a/.github/workflows/test-faststream-examples.yaml +++ b/.github/workflows/test-faststream-examples.yaml @@ -18,5 +18,5 @@ jobs: pip install -e ".[dev]" - name: Run pytest shell: bash - run: pytest + run: bash scripts/test.sh diff --git a/scripts/test.sh b/scripts/test.sh new file mode 100755 index 0000000..09960ab --- /dev/null +++ b/scripts/test.sh @@ -0,0 +1,5 @@ +#!/bin/bash + +coverage run -m pytest -x --ff "$@" || \ +coverage run -m pytest -x --ff "$@" || \ +coverage run -m pytest -x --ff "$@" From 646cc809049f951a215a91021774d06b10960f0d Mon Sep 17 00:00:00 2001 From: harishmohanraj Date: Wed, 11 Oct 2023 00:48:51 +0000 Subject: [PATCH 5/7] Add test script file --- .github/workflows/test-faststream-examples.yaml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test-faststream-examples.yaml b/.github/workflows/test-faststream-examples.yaml index 6ca455e..51874c6 100644 --- a/.github/workflows/test-faststream-examples.yaml +++ b/.github/workflows/test-faststream-examples.yaml @@ -18,5 +18,8 @@ jobs: pip install -e ".[dev]" - name: Run pytest shell: bash - run: bash scripts/test.sh + run: | + scripts/test.sh + scripts/test.sh docs_src/tutorial/calculate-mean-app/tests/test_application.py + scripts/test.sh docs_src/tutorial/retrieve-publish-crypto/tests/test_application.py From d8ba0d5397e82792dcd7c62f9d221f7229ba51db Mon Sep 17 00:00:00 2001 From: harishmohanraj Date: Wed, 11 Oct 2023 00:50:10 +0000 Subject: [PATCH 6/7] Add test script file --- .github/workflows/test-faststream-examples.yaml | 1 + docs_src/app_index_example/__init__.py | 0 2 files changed, 1 insertion(+) delete mode 100644 docs_src/app_index_example/__init__.py diff --git a/.github/workflows/test-faststream-examples.yaml b/.github/workflows/test-faststream-examples.yaml index 51874c6..bb3df83 100644 --- a/.github/workflows/test-faststream-examples.yaml +++ b/.github/workflows/test-faststream-examples.yaml @@ -22,4 +22,5 @@ jobs: scripts/test.sh scripts/test.sh docs_src/tutorial/calculate-mean-app/tests/test_application.py scripts/test.sh docs_src/tutorial/retrieve-publish-crypto/tests/test_application.py + scripts/test.sh docs_src/app_index_example/test.py diff --git a/docs_src/app_index_example/__init__.py b/docs_src/app_index_example/__init__.py deleted file mode 100644 index e69de29..0000000 From b3ad6d96f7c08b591aeeb553c828824e6713665d Mon Sep 17 00:00:00 2001 From: harishmohanraj Date: Wed, 11 Oct 2023 00:59:05 +0000 Subject: [PATCH 7/7] Update version --- faststream_gen/__init__.py | 2 +- settings.ini | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/faststream_gen/__init__.py b/faststream_gen/__init__.py index 5c796c0..429614a 100644 --- a/faststream_gen/__init__.py +++ b/faststream_gen/__init__.py @@ -1 +1 @@ -__version__ = "0.1.7rc0" \ No newline at end of file +__version__ = "0.1.7rc1" \ No newline at end of file diff --git a/settings.ini b/settings.ini index 9143a10..7b5404d 100644 --- a/settings.ini +++ b/settings.ini @@ -5,7 +5,7 @@ ### Python library ### repo = faststream-gen lib_name = %(repo)s -version = 0.1.7rc0 +version = 0.1.7rc1 min_python = 3.8 license = apache2 black_formatting = False