Skip to content
This repository has been archived by the owner on Dec 13, 2022. It is now read-only.

Commit

Permalink
Merge pull request #207 from open-contracting/tests
Browse files Browse the repository at this point in the history
Add test framework
  • Loading branch information
jpmckinney authored Mar 28, 2021
2 parents 0aefef0 + dd61aee commit a3e82cc
Show file tree
Hide file tree
Showing 9 changed files with 79 additions and 50 deletions.
27 changes: 27 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: CI
on: [push, pull_request]
env:
BASEDIR: https://raw.githubusercontent.com/open-contracting/standard-maintenance-scripts/main
jobs:
build:
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v1
with:
python-version: 3.6
- uses: actions/cache@v1
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements_dev.txt') }}
restore-keys: |
${{ runner.os }}-pip-
# Check requirements.txt contains production requirements.
- run: pip install -r requirements.txt
- run: ./manage.py --help
- run: pip install -r requirements_dev.txt
- run: coverage run --source content,country,covidadmin,vizualization manage.py test
if: always()
- env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: coveralls --service=github
13 changes: 13 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
repos:
- repo: https://github.com/psf/black
rev: 20.8b1
hooks:
- id: black
- repo: https://github.com/pycqa/flake8
rev: 3.8.4
hooks:
- id: flake8
- repo: https://github.com/pycqa/isort
rev: 5.6.4
hooks:
- id: isort
2 changes: 1 addition & 1 deletion country/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from rest_framework.response import Response
from rest_framework.views import APIView

from content.models import ImportBatch
from country.models import ImportBatch
from vizualization.views import add_filter_args

from .models import Buyer, Country, Language, OverallSummary, Supplier, Tender
Expand Down
31 changes: 23 additions & 8 deletions covidadmin/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,21 +20,36 @@
environ.Env.read_env()
env = environ.Env(
# set casting, default value
SECRET_KEY=(str, "ig0(igk8+n76thmh-@%*n4bc1ra3sq-#x)kx6bqf&zdh9n1*+8"),
DEBUG=(bool, False),
ALLOWED_HOSTS=(list, []),
DB_ENGINE=(str, "django.db.backends.postgresql_psycopg2"),
DB_NAME=(str, ""),
DB_USER=(str, ""),
DB_PASSWORD=(str, ""),
DB_HOST=(str, "127.0.0.1"),
DB_PORT=(int, 5432),
STATIC_URL=(str, "/static/"),
FORCE_SCRIPT_NAME=(str, "/"),
CORS_ORIGIN_WHITELIST=(list, []),
CELERY_BROKER_URL=(str, "pyamqp://localhost/"),
CELERY_TIMEZONE=(str, "UTC"),
FETCH_COVID_DATA_INTERVAL=(int, 10800),
GOOGLE_SHEET_CREDENTIALS_JSON=(str, ""),
FIXER_IO_API_KEY=(str, ""),
MEDIA_URL=(str, "/media/"),
)


sentry_sdk.init(
dsn=env("SENTRY_DSN"),
integrations=[DjangoIntegration()],
traces_sample_rate=1.0,
# If you wish to associate users to errors (assuming you are using
# django.contrib.auth) you may enable sending PII data.
send_default_pii=True,
)
if "SENTRY_DSN" in os.environ:
sentry_sdk.init(
dsn=env("SENTRY_DSN"),
integrations=[DjangoIntegration()],
traces_sample_rate=1.0,
# If you wish to associate users to errors (assuming you are using
# django.contrib.auth) you may enable sending PII data.
send_default_pii=True,
)

# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent
Expand Down
2 changes: 1 addition & 1 deletion requirements.in
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ djangorestframework
flower
gspread
pandas
psycopg2
psycopg2-binary
python-dateutil
requests
sentry_sdk
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ prometheus-client==0.8.0
# via flower
prompt-toolkit==3.0.8
# via click-repl
psycopg2==2.8.6
psycopg2-binary==2.8.6
# via -r requirements.in
pyasn1-modules==0.2.8
# via google-auth
Expand Down
3 changes: 1 addition & 2 deletions requirements_dev.in
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
-r requirements.txt
black
coveralls
flake8
ipdb
ipython
isort
pip-tools
pre-commit
pylint
pytest
transifex-client
48 changes: 11 additions & 37 deletions requirements_dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,6 @@ asgiref==3.2.10
# via
# -r requirements.txt
# django
astroid==2.4.2
# via pylint
attrs==20.3.0
# via pytest
backcall==0.2.0
# via ipython
beautifulsoup4==4.8.2
Expand Down Expand Up @@ -73,6 +69,10 @@ click==7.1.2
# click-didyoumean
# click-repl
# pip-tools
coverage==5.5
# via coveralls
coveralls==3.0.1
# via -r requirements_dev.in
dataclasses==0.8
# via black
decorator==4.4.2
Expand Down Expand Up @@ -120,6 +120,8 @@ djangorestframework==3.12.1
# via
# -r requirements.txt
# wagtail
docopt==0.6.2
# via coveralls
draftjs-exporter==2.1.7
# via
# -r requirements.txt
Expand Down Expand Up @@ -168,16 +170,12 @@ importlib-metadata==2.0.0
# -r requirements.txt
# flake8
# kombu
# pluggy
# pre-commit
# pytest
# virtualenv
importlib-resources==5.1.2
# via
# pre-commit
# virtualenv
iniconfig==1.1.1
# via pytest
ipdb==0.13.4
# via -r requirements_dev.in
ipython-genutils==0.2.0
Expand All @@ -187,9 +185,7 @@ ipython==7.16.1
# -r requirements_dev.in
# ipdb
isort==5.6.4
# via
# -r requirements_dev.in
# pylint
# via -r requirements_dev.in
jdcal==1.4.1
# via
# -r requirements.txt
Expand All @@ -204,12 +200,8 @@ l18n==2020.6.1
# via
# -r requirements.txt
# wagtail
lazy-object-proxy==1.4.3
# via astroid
mccabe==0.6.1
# via
# flake8
# pylint
# via flake8
mypy-extensions==0.4.3
# via black
nodeenv==1.5.0
Expand All @@ -226,8 +218,6 @@ openpyxl==3.0.5
# via
# -r requirements.txt
# tablib
packaging==20.9
# via pytest
pandas==1.1.5
# via -r requirements.txt
parso==0.7.1
Expand All @@ -244,8 +234,6 @@ pillow==8.1.2
# wagtail
pip-tools==5.5.0
# via -r requirements_dev.in
pluggy==0.13.1
# via pytest
pre-commit==2.11.1
# via -r requirements_dev.in
prometheus-client==0.8.0
Expand All @@ -257,12 +245,10 @@ prompt-toolkit==3.0.8
# -r requirements.txt
# click-repl
# ipython
psycopg2==2.8.6
psycopg2-binary==2.8.6
# via -r requirements.txt
ptyprocess==0.6.0
# via pexpect
py==1.10.0
# via pytest
pyasn1-modules==0.2.8
# via
# -r requirements.txt
Expand All @@ -278,12 +264,6 @@ pyflakes==2.2.0
# via flake8
pygments==2.7.2
# via ipython
pylint==2.6.0
# via -r requirements_dev.in
pyparsing==2.4.7
# via packaging
pytest==6.2.2
# via -r requirements_dev.in
python-dateutil==2.8.1
# via
# -r requirements.txt
Expand All @@ -310,6 +290,7 @@ requests-oauthlib==1.3.0
requests==2.24.0
# via
# -r requirements.txt
# coveralls
# gspread
# requests-oauthlib
# transifex-client
Expand All @@ -323,7 +304,6 @@ sentry-sdk==0.19.5
six==1.15.0
# via
# -r requirements.txt
# astroid
# click-repl
# google-auth
# html5lib
Expand Down Expand Up @@ -352,8 +332,6 @@ toml==0.10.2
# via
# black
# pre-commit
# pylint
# pytest
tornado==6.1
# via
# -r requirements.txt
Expand All @@ -363,9 +341,7 @@ traitlets==4.3.3
transifex-client==0.14.1
# via -r requirements_dev.in
typed-ast==1.4.1
# via
# astroid
# black
# via black
typing-extensions==3.7.4.3
# via black
unidecode==1.1.1
Expand Down Expand Up @@ -399,8 +375,6 @@ willow==1.4
# via
# -r requirements.txt
# wagtail
wrapt==1.12.1
# via astroid
xlrd==1.2.0
# via
# -r requirements.txt
Expand Down
1 change: 1 addition & 0 deletions vizualization/tests.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Delete this line once tests added.

0 comments on commit a3e82cc

Please sign in to comment.