This repository has been archived by the owner on Mar 31, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
19 changed files
with
262 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
[run] | ||
branch = True | ||
|
||
[report] | ||
exclude_lines = | ||
# Have to re-enable the standard pragma | ||
pragma: no cover | ||
|
||
# Don't complain about missing debug-only code: | ||
def __repr__ | ||
if self\.debug | ||
|
||
# Don't complain if tests don't hit defensive assertion code: | ||
raise AssertionError | ||
raise NotImplementedError | ||
|
||
# Don't complain if non-runnable code isn't run: | ||
if 0: | ||
if __name__ == .__main__.: | ||
ignore_errors = True | ||
omit = | ||
.venv/* | ||
venv/* | ||
|
||
[html] | ||
directory = htmlcov | ||
|
||
[paths] | ||
source = | ||
src/ | ||
tests/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
name: Cov Test CI | ||
|
||
on: | ||
push: | ||
branches: [ main ] | ||
pull_request: | ||
branches: [ main ] | ||
|
||
jobs: | ||
|
||
build: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
- name: Build the Docker image | ||
run: docker-compose build --no-cache | ||
|
||
- name: Run tests and upload coverage to Codecov | ||
run: | | ||
ci_env="bash <(curl -s https://codecov.io/env)" | ||
ci_post_cov="bash <(curl -s https://codecov.io/bash) -t ${{ secrets.CODECOV_TOKEN }}" | ||
docker-compose run -e CI=true --rm api bash -c "$ci_env && pytest && $ci_post_cov" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
FROM python:3.9.2-slim-buster | ||
|
||
ENV PYTHONUNBUFFERED 1 | ||
|
||
# Install prerequisites | ||
RUN apt-get update && \ | ||
apt-get upgrade -y && \ | ||
apt-get install -y curl && \ | ||
apt-get install -y git | ||
|
||
RUN pip install --upgrade pip | ||
|
||
RUN mkdir /app | ||
WORKDIR /app | ||
|
||
COPY requirements.txt /app/ | ||
RUN pip install -r requirements.txt | ||
|
||
COPY . /app/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
codecov: | ||
require_ci_to_pass: yes | ||
|
||
coverage: | ||
precision: 2 | ||
round: down | ||
range: "70...100" | ||
|
||
parsers: | ||
gcov: | ||
branch_detection: | ||
conditional: yes | ||
loop: yes | ||
method: no | ||
macro: no | ||
|
||
comment: | ||
layout: "reach,diff,flags,files,footer" | ||
behavior: default | ||
require_changes: no | ||
|
||
ignore: | ||
- "test/" | ||
- "*/**/test/*" | ||
- "**/test/" | ||
- "**/test/*" | ||
- "**/test/**/" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
version: "3.8" | ||
|
||
services: | ||
api: | ||
build: . | ||
ports: | ||
- "8000:8000" | ||
volumes: | ||
- .:/app |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#!/bin/bash | ||
python manage.py collectstatic --noinput | ||
python manage.py migrate --no-input | ||
python manage.py runserver 0.0.0.0:8000 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
[pytest] | ||
testpaths = . | ||
python_files = tests.py test_*.py *_tests.py | ||
;addopts = --flake8 -vv -s --cov=./ | ||
addopts = --flake8 --cov=. -vv -s --cov-report=html | ||
flake8-ignore = | ||
*.py E501 | ||
.venv |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
name: Cov Test CI | ||
|
||
on: | ||
push: | ||
branches: [ main ] | ||
pull_request: | ||
branches: [ main ] | ||
|
||
jobs: | ||
build: | ||
|
||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Set up Python 3.9 | ||
uses: actions/setup-python@v2 | ||
with: | ||
python-version: 3.9 | ||
|
||
- name: Install dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi | ||
- name: Test with pytest | ||
run: | | ||
pytest | ||
- name: Upload coverage to Codecov | ||
uses: codecov/codecov-action@v1 | ||
with: | ||
fail_ci_if_error: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
attrs==20.3.0 | ||
coverage==5.5 | ||
flake8==3.9.0 | ||
idna==3.1 | ||
iniconfig==1.1.1 | ||
mccabe==0.6.1 | ||
multidict==5.1.0 | ||
packaging==20.9 | ||
pluggy==0.13.1 | ||
py==1.10.0 | ||
pycodestyle==2.7.0 | ||
pyflakes==2.3.0 | ||
pyparsing==2.4.7 | ||
pytest==6.2.2 | ||
pytest-cov==2.11.1 | ||
pytest-flake8==1.0.7 | ||
PyYAML==5.4.1 | ||
six==1.15.0 | ||
toml==0.10.2 | ||
vcrpy==4.1.1 | ||
wrapt==1.12.1 | ||
yarl==1.6.3 |
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
def sum(a, b): | ||
return a + b | ||
|
||
|
||
def subtraction(a, b): | ||
return a - b | ||
|
||
|
||
# def sum_1(a, b, c): | ||
# return a + b + c | ||
# | ||
# | ||
# def subtraction_2(a, b, c): | ||
# return a - b - c |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
def division(a, b): | ||
return a / b | ||
|
||
|
||
def multiplication(a, b): | ||
return a * b | ||
|
||
|
||
# def multiplication_2(a, b, c, d): | ||
# return (a * b) + (c - d) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# def text_xx(a): | ||
# return a * 2 | ||
|
||
|
||
def text_xxx(a): | ||
return a * 3 | ||
|
||
|
||
def text_xxxx(a): | ||
return a * 4 | ||
|
||
|
||
# def text(a): | ||
# return a |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
from src.main import calc_01 | ||
import pytest | ||
|
||
|
||
@pytest.mark.parametrize('input,expected', [((2, 10), 12), ((3, 2), 5), ((5, 5), 10)]) | ||
def test_sum(input, expected): | ||
value_a, value_b = input | ||
result = calc_01.sum(value_a, value_b) | ||
assert result == expected | ||
|
||
|
||
@pytest.mark.parametrize('input,expected', [((3, 2), 1), ((10, 5), 5), ((17, 7), 10)]) | ||
def test_subtraction(input, expected): | ||
value_a, value_b = input | ||
result = calc_01.subtraction(value_a, value_b) | ||
assert result == expected |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
from src.main import calc_02 | ||
import pytest | ||
|
||
|
||
@pytest.mark.parametrize('input,expected', [((10, 2), 5), ((4, 2), 2), ((5, 5), 1)]) | ||
def test_division(input, expected): | ||
value_a, value_b = input | ||
result = calc_02.division(value_a, value_b) | ||
assert result == expected | ||
|
||
|
||
@pytest.mark.parametrize('input,expected', [((2, 10), 20), ((3, 2), 6), ((5, 5), 25)]) | ||
def test_multiplication(input, expected): | ||
value_a, value_b = input | ||
result = calc_02.multiplication(value_a, value_b) | ||
assert result == expected |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
from src.main import text | ||
import pytest | ||
|
||
|
||
@pytest.mark.parametrize('input,expected', [('a', 'aaa'), ('b', 'bbb'), ('c', 'ccc')]) | ||
def test_text_xxx(input, expected): | ||
result = text.text_xxx(input) | ||
assert result == expected | ||
|
||
|
||
@pytest.mark.parametrize('input,expected', [('a', 'aaaa'), ('b', 'bbbb'), ('c', 'cccc')]) | ||
def test_text_xxxx(input, expected): | ||
result = text.text_xxxx(input) | ||
assert result == expected |