Skip to content

Commit

Permalink
Coverage and other fixes (#55)
Browse files Browse the repository at this point in the history
* + coverage
+ pytest discover speed fixes
+ docker build, pip install thenewboston.tar.gz if available
+ flake8 rules to discuss
+ requests mocker
+ test with request mock
+ some fixes

* + missing connection request tests

* upgrade thenewboston package

* Bump thenewboston==0.0.21

Co-authored-by: Bucky <buckyroberts@gmail.com>
  • Loading branch information
vosi and buckyroberts authored Sep 30, 2020
1 parent f305b69 commit 9eac868
Show file tree
Hide file tree
Showing 19 changed files with 388 additions and 80 deletions.
23 changes: 23 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
[run]
omit = */tests/*
*/factories/*
*/migrations/*
*/urls.py
branch = True

include =
v1/*
; parallel = true
; concurrency = multiprocessing

[report]
precision = 2
ignore_errors = True
exclude_lines =
pragma: no cover
raise NotImplementedError
except ImportError
def __repr__
def __str__
if self\.logger\.debug
if __name__ == .__main__.:
16 changes: 16 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[flake8]
ignore = D203,D101,D400,D401,D106,W503,F403,F405,E501,D403,D104
exclude =
.git,
__pycache__,
migrations
filename =
*.py
max-complexity = 12
import-order-style = google
; application-import-names =
max-line-length = 120
max-linenumber = 500
accept-encodings = utf-8,utf-16
inline-quotes = single
multiline-quotes = double
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ sdist/
share/python-wheels/
var/
wheels/
thenewboston.tar.gz

# Unit test / coverage reports
*.cover
Expand Down Expand Up @@ -78,4 +79,4 @@ env.bak/
env/
venv
venv.bak/
venv/
venv/
5 changes: 3 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ FROM python:3.8

WORKDIR /opt/project

COPY requirements/local.txt .
COPY . .

RUN set -x; \
python3 -m pip install pip-tools; \
python3 -m pip install --no-cache-dir -r local.txt; \
python3 -m pip install --no-cache-dir -r requirements/local.txt; \
test -e thenewboston.tar.gz && python3 -m pip install thenewboston.tar.gz; \
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /root/.cache
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,13 @@ docker-compose run app pytest
docker-compose exec app pytest # if docker-compose run is running
```

To run tests with coverage report:
```
docker-compose run app pytest --cov=v1
# or
docker-compose exec app pytest --cov=v1 # if docker-compose run is running
```

To monitor Celery tasks:
```
docker-compose exec celery celery flower -A config.settings --address=127.0.0.1 --port=5555
Expand Down
1 change: 1 addition & 0 deletions pytest.ini
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
[pytest]
DJANGO_SETTINGS_MODULE = config.settings.local
python_files = tests/*.py
norecursedirs = .* .git *.egg build dist tmp* node_modules
7 changes: 4 additions & 3 deletions requirements/base.in
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
celery==4.4.2
django-debug-toolbar==2.2
django-debug-toolbar==3.1.1
django-filter==2.3.0
django-redis==4.11.0
flower==0.9.4
redis==3.5.2
requests-mock==1.8.0
tblib==1.6.0
thenewboston==0.0.19
wheel==0.34.2
thenewboston==0.0.21
wheel==0.35.1
23 changes: 13 additions & 10 deletions requirements/base.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,17 @@ channels-redis==2.4.2 # via thenewboston
channels==2.4.0 # via channels-redis, thenewboston
chardet==3.0.4 # via requests
constantly==15.1.0 # via twisted
coverage==5.3 # via pytest-cov
cryptography==3.1.1 # via autobahn, pyopenssl, service-identity
daphne==2.5.0 # via channels
django-cors-headers==3.4.0 # via thenewboston
django-debug-toolbar==2.2 # via -r requirements/base.in
django-debug-toolbar==3.1.1 # via -r requirements/base.in
django-filter==2.3.0 # via -r requirements/base.in
django-redis==4.11.0 # via -r requirements/base.in
django==3.1 # via channels, django-cors-headers, django-debug-toolbar, django-filter, django-redis, djangorestframework, thenewboston
django==3.1.1 # via channels, django-cors-headers, django-debug-toolbar, django-filter, django-redis, djangorestframework, thenewboston
djangorestframework==3.11.1 # via thenewboston
factory-boy==3.0.1 # via thenewboston
faker==4.1.3 # via factory-boy
faker==4.1.4 # via factory-boy
flower==0.9.4 # via -r requirements/base.in
hiredis==1.1.0 # via aioredis
humanize==0.5.1 # via flower
Expand All @@ -53,27 +54,29 @@ pynacl==1.3.0 # via thenewboston
pyopenssl==19.1.0 # via twisted
pyparsing==2.4.7 # via packaging
pytest-asyncio==0.14.0 # via thenewboston
pytest-django==3.9.0 # via thenewboston
pytest==6.0.1 # via pytest-asyncio, pytest-django, thenewboston
pytest-cov==2.10.1 # via thenewboston
pytest-django==3.10.0 # via thenewboston
pytest==6.0.2 # via pytest-asyncio, pytest-cov, pytest-django, thenewboston
python-dateutil==2.8.1 # via faker
pytz==2020.1 # via celery, django, flower
redis==3.5.2 # via -r requirements/base.in, django-redis
requests==2.23.0 # via thenewboston
requests-mock==1.8.0 # via -r requirements/base.in
requests==2.24.0 # via requests-mock, thenewboston
service-identity==18.1.0 # via twisted
six==1.15.0 # via automat, cryptography, packaging, pynacl, pyopenssl, python-dateutil
six==1.15.0 # via automat, cryptography, packaging, pynacl, pyopenssl, python-dateutil, requests-mock
sqlparse==0.3.1 # via django, django-debug-toolbar
tblib==1.6.0 # via -r requirements/base.in
text-unidecode==1.3 # via faker
thenewboston==0.0.19 # via -r requirements/base.in
thenewboston==0.0.21 # via -r requirements/base.in
toml==0.10.1 # via pytest
tornado==6.0.4 # via flower
twisted[tls]==20.3.0 # via daphne
txaio==20.4.1 # via autobahn
urllib3==1.25.10 # via requests
vine==1.3.0 # via amqp, celery
wheel==0.34.2 # via -r requirements/base.in
wheel==0.35.1 # via -r requirements/base.in
zipp==3.2.0 # via importlib-metadata
zope.interface==5.1.0 # via twisted
zope.interface==5.1.1 # via twisted

# The following packages are considered to be unsafe in a requirements file:
# setuptools
23 changes: 13 additions & 10 deletions requirements/development.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,17 @@ channels-redis==2.4.2 # via thenewboston
channels==2.4.0 # via channels-redis, thenewboston
chardet==3.0.4 # via requests
constantly==15.1.0 # via twisted
coverage==5.3 # via pytest-cov
cryptography==3.1.1 # via autobahn, pyopenssl, service-identity
daphne==2.5.0 # via channels
django-cors-headers==3.4.0 # via thenewboston
django-debug-toolbar==2.2 # via -r requirements/base.in
django-debug-toolbar==3.1.1 # via -r requirements/base.in
django-filter==2.3.0 # via -r requirements/base.in
django-redis==4.11.0 # via -r requirements/base.in
django==3.1 # via channels, django-cors-headers, django-debug-toolbar, django-filter, django-redis, djangorestframework, thenewboston
django==3.1.1 # via channels, django-cors-headers, django-debug-toolbar, django-filter, django-redis, djangorestframework, thenewboston
djangorestframework==3.11.1 # via thenewboston
factory-boy==3.0.1 # via thenewboston
faker==4.1.3 # via factory-boy
faker==4.1.4 # via factory-boy
flower==0.9.4 # via -r requirements/base.in
hiredis==1.1.0 # via aioredis
humanize==0.5.1 # via flower
Expand All @@ -53,27 +54,29 @@ pynacl==1.3.0 # via thenewboston
pyopenssl==19.1.0 # via twisted
pyparsing==2.4.7 # via packaging
pytest-asyncio==0.14.0 # via thenewboston
pytest-django==3.9.0 # via thenewboston
pytest==6.0.1 # via pytest-asyncio, pytest-django, thenewboston
pytest-cov==2.10.1 # via thenewboston
pytest-django==3.10.0 # via thenewboston
pytest==6.0.2 # via pytest-asyncio, pytest-cov, pytest-django, thenewboston
python-dateutil==2.8.1 # via faker
pytz==2020.1 # via celery, django, flower
redis==3.5.2 # via -r requirements/base.in, django-redis
requests==2.23.0 # via thenewboston
requests-mock==1.8.0 # via -r requirements/base.in
requests==2.24.0 # via requests-mock, thenewboston
service-identity==18.1.0 # via twisted
six==1.15.0 # via automat, cryptography, packaging, pynacl, pyopenssl, python-dateutil
six==1.15.0 # via automat, cryptography, packaging, pynacl, pyopenssl, python-dateutil, requests-mock
sqlparse==0.3.1 # via django, django-debug-toolbar
tblib==1.6.0 # via -r requirements/base.in
text-unidecode==1.3 # via faker
thenewboston==0.0.19 # via -r requirements/base.in
thenewboston==0.0.21 # via -r requirements/base.in
toml==0.10.1 # via pytest
tornado==6.0.4 # via flower
twisted[tls]==20.3.0 # via daphne
txaio==20.4.1 # via autobahn
urllib3==1.25.10 # via requests
vine==1.3.0 # via amqp, celery
wheel==0.34.2 # via -r requirements/base.in
wheel==0.35.1 # via -r requirements/base.in
zipp==3.2.0 # via importlib-metadata
zope.interface==5.1.0 # via twisted
zope.interface==5.1.1 # via twisted

# The following packages are considered to be unsafe in a requirements file:
# setuptools
23 changes: 13 additions & 10 deletions requirements/local.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,17 @@ channels-redis==2.4.2 # via thenewboston
channels==2.4.0 # via channels-redis, thenewboston
chardet==3.0.4 # via requests
constantly==15.1.0 # via twisted
coverage==5.3 # via pytest-cov
cryptography==3.1.1 # via autobahn, pyopenssl, service-identity
daphne==2.5.0 # via channels
django-cors-headers==3.4.0 # via thenewboston
django-debug-toolbar==2.2 # via -r requirements/base.in
django-debug-toolbar==3.1.1 # via -r requirements/base.in
django-filter==2.3.0 # via -r requirements/base.in
django-redis==4.11.0 # via -r requirements/base.in
django==3.1 # via channels, django-cors-headers, django-debug-toolbar, django-filter, django-redis, djangorestframework, thenewboston
django==3.1.1 # via channels, django-cors-headers, django-debug-toolbar, django-filter, django-redis, djangorestframework, thenewboston
djangorestframework==3.11.1 # via thenewboston
factory-boy==3.0.1 # via thenewboston
faker==4.1.3 # via factory-boy
faker==4.1.4 # via factory-boy
flower==0.9.4 # via -r requirements/base.in
hiredis==1.1.0 # via aioredis
humanize==0.5.1 # via flower
Expand All @@ -54,27 +55,29 @@ pynacl==1.3.0 # via thenewboston
pyopenssl==19.1.0 # via twisted
pyparsing==2.4.7 # via packaging
pytest-asyncio==0.14.0 # via thenewboston
pytest-django==3.9.0 # via thenewboston
pytest==6.0.1 # via pytest-asyncio, pytest-django, thenewboston
pytest-cov==2.10.1 # via thenewboston
pytest-django==3.10.0 # via thenewboston
pytest==6.0.2 # via pytest-asyncio, pytest-cov, pytest-django, thenewboston
python-dateutil==2.8.1 # via faker
pytz==2020.1 # via celery, django, flower
redis==3.5.2 # via -r requirements/base.in, django-redis
requests==2.23.0 # via thenewboston
requests-mock==1.8.0 # via -r requirements/base.in
requests==2.24.0 # via requests-mock, thenewboston
service-identity==18.1.0 # via twisted
six==1.15.0 # via automat, cryptography, packaging, pynacl, pyopenssl, python-dateutil
six==1.15.0 # via automat, cryptography, packaging, pynacl, pyopenssl, python-dateutil, requests-mock
sqlparse==0.3.1 # via django, django-debug-toolbar
tblib==1.6.0 # via -r requirements/base.in
text-unidecode==1.3 # via faker
thenewboston==0.0.19 # via -r requirements/base.in
thenewboston==0.0.21 # via -r requirements/base.in
toml==0.10.1 # via pytest
tornado==6.0.4 # via flower
twisted[tls]==20.3.0 # via daphne
txaio==20.4.1 # via autobahn
urllib3==1.25.10 # via requests
vine==1.3.0 # via amqp, celery
wheel==0.34.2 # via -r requirements/base.in
wheel==0.35.1 # via -r requirements/base.in
zipp==3.2.0 # via importlib-metadata
zope.interface==5.1.0 # via twisted
zope.interface==5.1.1 # via twisted

# The following packages are considered to be unsafe in a requirements file:
# setuptools
23 changes: 13 additions & 10 deletions requirements/production.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,17 @@ channels-redis==2.4.2 # via thenewboston
channels==2.4.0 # via channels-redis, thenewboston
chardet==3.0.4 # via requests
constantly==15.1.0 # via twisted
coverage==5.3 # via pytest-cov
cryptography==3.1.1 # via autobahn, pyopenssl, service-identity
daphne==2.5.0 # via channels
django-cors-headers==3.4.0 # via thenewboston
django-debug-toolbar==2.2 # via -r requirements/base.in
django-debug-toolbar==3.1.1 # via -r requirements/base.in
django-filter==2.3.0 # via -r requirements/base.in
django-redis==4.11.0 # via -r requirements/base.in
django==3.1 # via channels, django-cors-headers, django-debug-toolbar, django-filter, django-redis, djangorestframework, thenewboston
django==3.1.1 # via channels, django-cors-headers, django-debug-toolbar, django-filter, django-redis, djangorestframework, thenewboston
djangorestframework==3.11.1 # via thenewboston
factory-boy==3.0.1 # via thenewboston
faker==4.1.3 # via factory-boy
faker==4.1.4 # via factory-boy
flower==0.9.4 # via -r requirements/base.in
hiredis==1.1.0 # via aioredis
humanize==0.5.1 # via flower
Expand All @@ -53,27 +54,29 @@ pynacl==1.3.0 # via thenewboston
pyopenssl==19.1.0 # via twisted
pyparsing==2.4.7 # via packaging
pytest-asyncio==0.14.0 # via thenewboston
pytest-django==3.9.0 # via thenewboston
pytest==6.0.1 # via pytest-asyncio, pytest-django, thenewboston
pytest-cov==2.10.1 # via thenewboston
pytest-django==3.10.0 # via thenewboston
pytest==6.0.2 # via pytest-asyncio, pytest-cov, pytest-django, thenewboston
python-dateutil==2.8.1 # via faker
pytz==2020.1 # via celery, django, flower
redis==3.5.2 # via -r requirements/base.in, django-redis
requests==2.23.0 # via thenewboston
requests-mock==1.8.0 # via -r requirements/base.in
requests==2.24.0 # via requests-mock, thenewboston
service-identity==18.1.0 # via twisted
six==1.15.0 # via automat, cryptography, packaging, pynacl, pyopenssl, python-dateutil
six==1.15.0 # via automat, cryptography, packaging, pynacl, pyopenssl, python-dateutil, requests-mock
sqlparse==0.3.1 # via django, django-debug-toolbar
tblib==1.6.0 # via -r requirements/base.in
text-unidecode==1.3 # via faker
thenewboston==0.0.19 # via -r requirements/base.in
thenewboston==0.0.21 # via -r requirements/base.in
toml==0.10.1 # via pytest
tornado==6.0.4 # via flower
twisted[tls]==20.3.0 # via daphne
txaio==20.4.1 # via autobahn
urllib3==1.25.10 # via requests
vine==1.3.0 # via amqp, celery
wheel==0.34.2 # via -r requirements/base.in
wheel==0.35.1 # via -r requirements/base.in
zipp==3.2.0 # via importlib-metadata
zope.interface==5.1.0 # via twisted
zope.interface==5.1.1 # via twisted

# The following packages are considered to be unsafe in a requirements file:
# setuptools
23 changes: 13 additions & 10 deletions requirements/staging.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,17 @@ channels-redis==2.4.2 # via thenewboston
channels==2.4.0 # via channels-redis, thenewboston
chardet==3.0.4 # via requests
constantly==15.1.0 # via twisted
coverage==5.3 # via pytest-cov
cryptography==3.1.1 # via autobahn, pyopenssl, service-identity
daphne==2.5.0 # via channels
django-cors-headers==3.4.0 # via thenewboston
django-debug-toolbar==2.2 # via -r requirements/base.in
django-debug-toolbar==3.1.1 # via -r requirements/base.in
django-filter==2.3.0 # via -r requirements/base.in
django-redis==4.11.0 # via -r requirements/base.in
django==3.1 # via channels, django-cors-headers, django-debug-toolbar, django-filter, django-redis, djangorestframework, thenewboston
django==3.1.1 # via channels, django-cors-headers, django-debug-toolbar, django-filter, django-redis, djangorestframework, thenewboston
djangorestframework==3.11.1 # via thenewboston
factory-boy==3.0.1 # via thenewboston
faker==4.1.3 # via factory-boy
faker==4.1.4 # via factory-boy
flower==0.9.4 # via -r requirements/base.in
hiredis==1.1.0 # via aioredis
humanize==0.5.1 # via flower
Expand All @@ -53,27 +54,29 @@ pynacl==1.3.0 # via thenewboston
pyopenssl==19.1.0 # via twisted
pyparsing==2.4.7 # via packaging
pytest-asyncio==0.14.0 # via thenewboston
pytest-django==3.9.0 # via thenewboston
pytest==6.0.1 # via pytest-asyncio, pytest-django, thenewboston
pytest-cov==2.10.1 # via thenewboston
pytest-django==3.10.0 # via thenewboston
pytest==6.0.2 # via pytest-asyncio, pytest-cov, pytest-django, thenewboston
python-dateutil==2.8.1 # via faker
pytz==2020.1 # via celery, django, flower
redis==3.5.2 # via -r requirements/base.in, django-redis
requests==2.23.0 # via thenewboston
requests-mock==1.8.0 # via -r requirements/base.in
requests==2.24.0 # via requests-mock, thenewboston
service-identity==18.1.0 # via twisted
six==1.15.0 # via automat, cryptography, packaging, pynacl, pyopenssl, python-dateutil
six==1.15.0 # via automat, cryptography, packaging, pynacl, pyopenssl, python-dateutil, requests-mock
sqlparse==0.3.1 # via django, django-debug-toolbar
tblib==1.6.0 # via -r requirements/base.in
text-unidecode==1.3 # via faker
thenewboston==0.0.19 # via -r requirements/base.in
thenewboston==0.0.21 # via -r requirements/base.in
toml==0.10.1 # via pytest
tornado==6.0.4 # via flower
twisted[tls]==20.3.0 # via daphne
txaio==20.4.1 # via autobahn
urllib3==1.25.10 # via requests
vine==1.3.0 # via amqp, celery
wheel==0.34.2 # via -r requirements/base.in
wheel==0.35.1 # via -r requirements/base.in
zipp==3.2.0 # via importlib-metadata
zope.interface==5.1.0 # via twisted
zope.interface==5.1.1 # via twisted

# The following packages are considered to be unsafe in a requirements file:
# setuptools
Empty file modified scripts/compile_requirements.sh
100644 → 100755
Empty file.
Loading

0 comments on commit 9eac868

Please sign in to comment.