Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/issue 144/testing action #155

Closed
wants to merge 11 commits into from
54 changes: 54 additions & 0 deletions .github/workflows/python-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: Python Tests

on:
pull_request:
branches:
- staging

jobs:
test:
runs-on: ubuntu-latest

strategy:
matrix:
python-version: ["3.10"]

steps:
- name: Checkout code
uses: actions/checkout@v2
with:
fetch-depth: 0

- name: switch to branch
run: git checkout ${{ github.event.pull_request.head.ref }}

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install pytest
pip install -r requirements.txt

- name: Set DJANGO_SETTINGS_MODULE environment variable
run: echo "DJANGO_SETTINGS_MODULE=config.settings" >> $GITHUB_ENV

- name: Run tests with pytest
run: pytest
env:
SECRET_KEY: ${{ secrets.SECRET_KEY }}
DATABASE_URL: ${{ secrets.DATABASE_URL }}
DEBUG: ${{ secrets.DEBUG }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_STORAGE_BUCKET_NAME: ${{ secrets.AWS_STORAGE_BUCKET_NAME }}
EMAIL_HOST: ${{ secrets.EMAIL_HOST }}
EMAIL_HOST_USER: ${{ secrets.EMAIL_HOST_USER }}
EMAIL_HOST_PASSWORD: ${{ secrets.EMAIL_HOST_PASSWORD }}
SENTRY_DSN: ${{ secrets.SENTRY_DSN }}
CELERY_BROKER_URL: ${{ secrets.CELERY_BROKER_URL }}
CELERY_RESULT_BACKEND: ${{ secrets.CELERY_RESULT_BACKEND }}
CELERY_TIMEZONE: ${{ secrets.CELERY_TIMEZONE }}
86 changes: 86 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
amqp==5.1.1
asgiref==3.7.2
async-timeout==4.0.3
autopep8==2.0.1
billiard==4.1.0
boto3==1.28.57
botocore==1.31.57
celery==5.3.4
certifi==2023.7.22
cffi==1.16.0
cfgv==3.4.0
charset-normalizer==3.3.0
click==8.1.7
click-didyoumean==0.3.0
click-plugins==1.1.1
click-repl==0.3.0
coreapi==2.3.3
coreschema==0.0.4
coverage==7.3.1
cron-descriptor==1.4.0
cryptography==41.0.4
defusedxml==0.8.0rc2
distlib==0.3.7
Django==4.2.5
django-appconf==1.0.5
django-celery-beat==2.5.0
django-cors-headers==4.2.0
django-environ==0.11.2
django-extensions==3.2.3
django-imagekit==5.0.0
django-multiselectfield==0.1.12
django-phonenumber-field==7.1.0
django-storages==1.14.1
django-templated-mail==1.1.1
django-timezone-field==6.0.1
djangorestframework==3.14.0
djangorestframework-simplejwt==5.3.0
djoser==2.2.0
filelock==3.12.4
flake8==6.1.0
gunicorn==21.2.0
identify==2.5.30
idna==3.4
itypes==1.2.0
Jinja2==3.1.2
jmespath==1.0.1
kombu==5.3.2
MarkupSafe==2.1.2
mccabe==0.7.0
nodeenv==1.8.0
oauthlib==3.2.2
packaging==23.2
phonenumbers==8.13.22
pilkit==3.0
Pillow==10.0.1
platformdirs==3.10.0
pre-commit==3.4.0
prompt-toolkit==3.0.39
psycopg2-binary==2.9.8
pycodestyle==2.11.0
pycparser==2.21
pyflakes==3.1.0
PyJWT==2.8.0
python-crontab==3.0.0
python-dateutil==2.8.2
python3-openid==3.2.0
pytz==2023.3.post1
PyYAML==6.0.1
redis==5.0.1
requests==2.31.0
requests-oauthlib==1.3.1
s3transfer==0.7.0
sentry-sdk==1.31.0
six==1.16.0
social-auth-app-django==5.3.0
social-auth-core==4.4.2
sqlparse==0.4.4
tomli==2.0.1
typing_extensions==4.8.0
tzdata==2023.3
uritemplate==4.1.1
urllib3==1.26.16
vine==5.0.0
virtualenv==20.24.5
wcwidth==0.2.8
whitenoise==6.5.0
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
class MentorModelTest(TestCase):

def setUp(self):
# Assuming CustomUser has a username and password
self.user = CustomUser.objects.create(username='testuser',
password='password123')

Expand All @@ -17,8 +16,6 @@ def test_mentor_creation(self):
skills=['HTML', 'CSS', 'Django']
)

# Assert that the mentor object was saved and has the correct
# attributes
self.assertEqual(mentor.about_me, 'This is a test about me.')
self.assertEqual(mentor.team_number, 5)
self.assertListEqual(list(mentor.skills), ['HTML', 'CSS', 'Django'])
Expand All @@ -31,25 +28,20 @@ def test_str_representation(self):
skills=['HTML']
)

# Assert that the __str__ method returns the correct representation
self.assertEqual(str(mentor), 'testuser')

def test_default_about_me(self):
# Create a Mentor object without specifying an 'about_me'
mentor = Mentor.objects.create(
user=self.user,
skills=['HTML']
)

# Assert that the default value for 'about_me' is set
self.assertEqual(mentor.about_me, '')

def test_default_team_number(self):
# Create a Mentor object without specifying a 'team_number'
mentor = Mentor.objects.create(
user=self.user,
skills=['HTML']
)

# Assert that the default value for 'team_number' is set
self.assertEqual(mentor.team_number, 0)
Loading