Skip to content

Commit aa36a60

Browse files
committed
init localtesting with pytest-django
1 parent 3fcef3a commit aa36a60

File tree

4 files changed

+58
-2
lines changed

4 files changed

+58
-2
lines changed

.github/workflows/pull-request-merge-precondition.yml

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@ name: Pull Request Merge Precondition
33
on:
44
pull_request:
55

6+
permissions:
7+
contents: read
8+
pull-requests: write
9+
610
jobs:
711
build:
812
runs-on: ubuntu-latest
@@ -11,7 +15,11 @@ jobs:
1115
python-version: [3.8]
1216

1317
steps:
14-
- uses: actions/checkout@v2
18+
- uses: actions/checkout@v3
19+
with:
20+
persist-credentials: true # otherwise, the token used is the GITHUB_TOKEN, instead of your personal token
21+
fetch-depth: 0 # otherwise, you will failed to push refs to dest repo
22+
1523
- uses: psf/black@stable
1624
with:
1725
options: "--check --verbose --exclude migrations"
@@ -20,3 +28,20 @@ jobs:
2028
with:
2129
configuration: "--check-only --diff --profile black"
2230
requirementsFiles: "requirements.txt"
31+
32+
- name: install dependencies
33+
run: |
34+
python -m pip install --upgrade pip
35+
pip install -r requirements.txt
36+
pip install -r requirements-dev.txt
37+
pip install pytest-cov
38+
39+
- name: run pytest
40+
run: |
41+
pytest --junitxml=pytest.xml --cov-report=term-missing:skip-covered --cov=pyconkr ./ | tee pytest-coverage.txt
42+
43+
#- name: Pytest coverage comment
44+
# uses: MishaKav/pytest-coverage-comment@main
45+
# with:
46+
# pytest-coverage-path: ./pytest-coverage.txt
47+
# junitxml-path: ./pytest.xml

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,11 @@
1010
* mac
1111
* brew install mysql-client
1212
* pip install -r requirements.txt
13+
14+
## how to run localtesting ( sqlite3 based )
15+
```
16+
# to setup pytest and requirements
17+
pip install -r requirements-dev.txt
18+
# run test
19+
pytest
20+
```

manage.py

100644100755
File mode changed.

sponsor/tests.py

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,26 @@
1-
from django.test import TestCase
1+
import pytest
2+
from django.contrib.auth import get_user_model
3+
4+
from sponsor.models import SponsorLevel
5+
6+
pytestmark = pytest.mark.django_db
7+
8+
UserModel = get_user_model()
9+
10+
11+
@pytest.mark.django_db
12+
class TestSponsorLevelModel:
13+
pytestmark = pytest.mark.django_db
14+
15+
def test_sponsor_level_creation_success(self):
16+
assert SponsorLevel.objects.count() == 0
17+
SponsorLevel.objects.create(
18+
name="test",
19+
desc="test desc",
20+
visible=True,
21+
limit=1,
22+
)
23+
assert SponsorLevel.objects.count() != 0
24+
225

326
# Create your tests here.

0 commit comments

Comments
 (0)