diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index 7e84fa8..d79e33a 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -3,11 +3,11 @@ on: push: branches: - main - - tidyup + - coverage pull_request: branches: - main - - tidyup + - coverage jobs: install: @@ -34,12 +34,22 @@ jobs: cd ScheduleBuilder pip install -r requirements.txt - - name: Run Tests with Coverage + - name: Run Account Tests with Coverage env: CAL_ID: c_6ed17073345c64d5b392f5a8ef7b4a62938f12c8fc5fecfa4b7256ef88acad28@group.calendar.google.com run: | - cd ScheduleBuilder/google_calendar - pytest --cov=./ --cov-report=xml test.py + cd ScheduleBuilder + python manage.py makemigrations + python manage.py migrate + cd account + pytest --cov=./ regtests.py + + + - name: Create Coverage Report + run: | + cd ScheduleBuilder + coverage combine account/.coverage + coverage xml -o coverage.xml - name: Upload Coverage to Codecov uses: codecov/codecov-action@v3 @@ -47,5 +57,5 @@ jobs: CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} with: token: ${{ secrets.CODECOV_TOKEN }} - files: ./ScheduleBuilder/google_calendar/coverage.xml + files: ./ScheduleBuilder/coverage.xml fail_ci_if_error: true diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index d14ae98..caa3ef3 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -4,11 +4,11 @@ on: push: branches: - main - - tidyup + - coverage pull_request: branches: - main - - tidyup + - coverage jobs: install: @@ -34,10 +34,13 @@ jobs: run: | cd ScheduleBuilder pip install -r requirements.txt - - - name: Run Tests + + - name: Run Account Tests env: CAL_ID: c_6ed17073345c64d5b392f5a8ef7b4a62938f12c8fc5fecfa4b7256ef88acad28@group.calendar.google.com run: | - cd ScheduleBuilder/google_calendar - pytest test.py + cd ScheduleBuilder + python manage.py makemigrations + python manage.py migrate + cd account + pytest regtests.py diff --git a/README.md b/README.md index dd69a4f..494e890 100644 --- a/README.md +++ b/README.md @@ -76,4 +76,8 @@ Then go to the browser and enter the url **http://127.0.0.1:8000/** - Remove friends - Add friends to events * PyTest - - Implementated unit tests for google calendar + - Implementated unit tests for google calendar and accounts +* CI/CD + - Django build badge + - Django tests badge + - Test coverage badge diff --git a/ScheduleBuilder/account/regtests.py b/ScheduleBuilder/account/regtests.py index 5633fbd..d2c364c 100644 --- a/ScheduleBuilder/account/regtests.py +++ b/ScheduleBuilder/account/regtests.py @@ -100,4 +100,4 @@ def test_create_user_no_username_sad(): username='', # Empty username should raise ValueError password='testpassword', ) - print(f"Exception message: {e}") \ No newline at end of file + print(f"Exception message: {e}")