diff --git a/.github/workflows/regression-test.yml b/.github/workflows/regression-test.yml new file mode 100644 index 000000000..7ca436d9b --- /dev/null +++ b/.github/workflows/regression-test.yml @@ -0,0 +1,36 @@ +name: Run Regression Tests + +on: + schedule: + - cron: '*/15 * * * *' # Runs every 15 minutes + workflow_dispatch: + + +jobs: + run-newman-test: + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Set up Node.js + uses: actions/setup-node@v4 + with: + node-version: "20" + + - name: Install Newman + run: | + npm install -g newman + + - name: Run Newman Tests + run: | + newman run qa_tests/Boilerplate-status-page.postman_collection.json -r json --reporter-json-export=result.json --suppress-exit-code + + - name: Copy result.json to server + uses: appleboy/scp-action@v0.1.7 + with: + host: ${{ secrets.HOST }} + username: ${{ secrets.USERNAME }} + password: ${{ secrets.PASSWORD }} + source: "result.json" + target: "/home/${{ secrets.USERNAME }}/hng_boilerplate_python_fastapi_web/staging" diff --git a/.gitignore b/.gitignore index 6e228fe5e..c0782126f 100644 --- a/.gitignore +++ b/.gitignore @@ -29,7 +29,7 @@ MANIFEST test_case1.py api/core/dependencies/mailjet.py tests/v1/waitlist/waitlist_test.py - +result.json # PyInstaller # Usually these files are written by a python script from a template # before PyInstaller builds the exe, so as to inject date/other infos into it. diff --git a/api/v1/routes/newsletter.py b/api/v1/routes/newsletter.py index 2fc6b857c..c8ddf33a6 100644 --- a/api/v1/routes/newsletter.py +++ b/api/v1/routes/newsletter.py @@ -37,20 +37,23 @@ async def sub_newsletter( # Save user to the database NewsletterService.create(db, request) - link = "https://anchor-python.teams.hng.tech/" - - # Send email in the background - background_tasks.add_task( - send_email, - recipient=request.email, - template_name="newsletter-subscription.html", - subject="Thank You for Subscribing to HNG Boilerplate Newsletters", - context={"link": link}, - ) + link = "https://anchor-python.teams.hng.tech/" + + # Send email in the background + background_tasks.add_task( + send_email, + recipient=request.email, + template_name="newsletter-subscription.html", + subject="Thank You for Subscribing to HNG Boilerplate Newsletters", + context={"link": link}, + ) + message = "Thank you for subscribing to our newsletter." + else: + message = "You have already subscribed to our newsletter. Thank you." return success_response( - message="Thank you for subscribing to our newsletter.", - status_code=status.HTTP_201_CREATED, + message=message, + status_code=status.HTTP_200_OK, ) diff --git a/requirements.txt b/requirements.txt index 615342171..e8b8a8e48 100644 --- a/requirements.txt +++ b/requirements.txt @@ -6,6 +6,7 @@ alembic==1.13.2 annotated-types==0.7.0 anyio==4.4.0 astroid==3.2.4 +async-timeout==4.0.3 attrs==23.2.0 Authlib==1.3.1 autopep8==2.3.1 @@ -23,6 +24,7 @@ colorama==0.4.6 cryptography==43.0.0 cssselect==1.2.0 cssutils==2.11.1 +Deprecated==1.2.14 dill==0.3.8 distlib==0.3.8 dnspython==2.6.1 @@ -37,17 +39,18 @@ filelock==3.15.4 flake8==7.1.0 frozenlist==1.4.1 greenlet==3.0.3 -slowapi==0.1.9 h11==0.14.0 httpcore==1.0.5 httptools==0.6.1 httpx==0.27.0 identify==2.6.0 idna==3.7 +importlib_resources==6.4.4 iniconfig==2.0.0 isort==5.13.2 itsdangerous==2.2.0 Jinja2==3.1.4 +limits==3.13.0 lxml==5.2.2 Mako==1.3.5 markdown-it-py==3.0.0 @@ -61,8 +64,8 @@ nodeenv==1.9.1 packaging==24.1 passlib==1.7.4 pathspec==0.12.1 +pillow==10.4.0 pipdeptree==2.23.1 -Pillow==10.4.0 platformdirs==4.2.2 pluggy==1.5.0 pre-commit==3.7.1 @@ -94,9 +97,11 @@ rich==13.7.1 rsa==4.9 shellingham==1.5.4 six==1.16.0 +slowapi==0.1.9 sniffio==1.3.1 SQLAlchemy==2.0.31 starlette==0.37.2 +stripe==10.7.0 tomli==2.0.1 tomlkit==0.13.0 twilio==9.2.3 @@ -110,5 +115,5 @@ virtualenv==20.26.3 watchfiles==0.22.0 webencodings==0.5.1 websockets==12.0 +wrapt==1.16.0 yarl==1.9.4 -stripe==10.7.0