Skip to content

Commit

Permalink
Add basic test configuration.
Browse files Browse the repository at this point in the history
Add test for app.py.
Modified CI to run tests.
  • Loading branch information
inifares23lab committed Dec 7, 2023
1 parent b5585ad commit 1d87eeb
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 11 deletions.
17 changes: 8 additions & 9 deletions .github/workflows/parser_ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11"]
python-version: [ "3.8", "3.9", "3.10", "3.11", "3.12" ]

steps:
- uses: actions/checkout@v3
Expand Down Expand Up @@ -57,16 +57,15 @@ jobs:
file_name="nx.html"
[[ -f ./$file_name ]] && echo "$file_name created - OK" || exit 1
- name: Run app.py server
run: |
python app.py &
- name: Check that the server is reachable
run: |
head=$(curl --head http://127.0.0.1:8050/ | head -n 1)
[[ $head = *"200 OK"* ]] && echo "$head" || exit 1
- name: Prepare for tests
run: pip install -r requirements_test.txt

- name: Run pytest
run: pytest .

do_something_else:
runs-on: ubuntu-latest
needs: test_parser
steps:
- run: echo "Doing something else"
- name: Do something else
run: echo "Doing something else"
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
file.*
*test*
*test
conf/conf.env
__pycache__
*__pycache__
certs/*
output.*
graph.py
Expand All @@ -13,3 +13,4 @@ tmp
.vscode
*.log
.ropeproject
*cache*
1 change: 1 addition & 0 deletions requirements_test.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pytest
Empty file added tests/__init__.py
Empty file.
14 changes: 14 additions & 0 deletions tests/test_app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import pytest

# Assuming the Dash app is initialized in a file named app.py and the server is an attribute of the app
from app import app


@pytest.fixture(scope='module')
def client():
return app.server.test_client()

def test_server_is_up_and_running(client):
response = client.head('http://127.0.0.1:8050/')
assert response.status_code == 200

0 comments on commit 1d87eeb

Please sign in to comment.