Skip to content

Commit

Permalink
tests: added tests for scripts #58
Browse files Browse the repository at this point in the history
  • Loading branch information
itisallgood committed Mar 23, 2020
1 parent 2ee5c55 commit f814312
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 3 deletions.
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ go-docker = "scripts.poetry_scripts:go_docker"
create-coverage = "scripts.poetry_scripts:coverage_report"
check-coverage = "scripts.poetry_scripts:check_coverage"
codecov-report = "scripts.poetry_scripts:coverage_xml"
generate-requirements = "scripts.poetry_scripts:generate_requirements"

[build-system]
requires = ["poetry>=0.12"]
Expand Down
6 changes: 3 additions & 3 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -175,9 +175,9 @@ ruamel.yaml.clib==0.2.0; platform_python_implementation == "CPython" and python_
--hash=sha256:b66832ea8077d9b3f6e311c4a53d06273db5dc2db6e8a908550f3c14d67e718c
saasy==0.0.1 \
--hash=sha256:bd04101cbb066bf7db7d312d11729af570a97dc11a13a68b111bf5bb541acca6
sentry-sdk==0.14.2 \
--hash=sha256:480eee754e60bcae983787a9a13bc8f155a111aef199afaa4f289d6a76aa622a \
--hash=sha256:a920387dc3ee252a66679d0afecd34479fb6fc52c2bc20763793ed69e5b0dcc0
sentry-sdk==0.14.3 \
--hash=sha256:bb90a4e19c7233a580715fc986cc44be2c48fc10b31e71580a2037e1c94b6950 \
--hash=sha256:23808d571d2461a4ce3784ec12bbee5bdb8c026c143fe79d36cef8a6d653e71f
six==1.14.0 \
--hash=sha256:8f3cd2e254d8f793e7f3d6d9df77b92252b52637291d0f0da013c76ea2724b6c \
--hash=sha256:236bdbdce46e6e6a3d61a337c0f8b763ca1e8717c03b369e87a7ec7ce1319c0a
Expand Down
9 changes: 9 additions & 0 deletions scripts/poetry_scripts.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,25 @@


def go_docker():
"""Script for starting the containers in the background and leaving them running."""
os.system("docker-compose up -d")


def coverage_report():
"""Script for running coverage tests."""
os.system("coverage run -m py.test")


def coverage_xml():
"""Script for creating xml report on coverage."""
os.system("coverage xml")


def check_coverage():
"""Script for creating coverage report."""
os.system("coverage report --fail-under=95")


def generate_requirements():
"""Script for generating requirements.txt from pyproject.toml"""
os.system("poetry export -f requirements.txt > requirements.txt")
44 changes: 44 additions & 0 deletions scripts/tests/test_poetry_scripts.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
from scripts.poetry_scripts import (
check_coverage,
coverage_report,
coverage_xml,
generate_requirements,
go_docker,
)


def test_go_docker(mocker):
"""Test go_docker function from scripts.poetry_scripts"""
mocked_function = mocker.patch("os.system")
go_docker()
mocked_function.assert_called_once_with("docker-compose up -d")


def test_coverage_report(mocker):
"""Test coverage_report function from scripts.poetry_scripts"""
mocked_function = mocker.patch("os.system")
coverage_report()
mocked_function.assert_called_once_with("coverage run -m py.test")


def test_coverage_xml(mocker):
"""Test coverage_xml function from scripts.poetry_scripts"""
mocked_function = mocker.patch("os.system")
coverage_xml()
mocked_function.assert_called_once_with("coverage xml")


def test_check_coverage(mocker):
"""Test check_coverage function from scripts.poetry_scripts"""
mocked_function = mocker.patch("os.system")
check_coverage()
mocked_function.assert_called_once_with("coverage report --fail-under=95")


def test_generate_requirements(mocker):
"""Test check_coverage function from scripts.poetry_scripts"""
mocked_function = mocker.patch("os.system")
generate_requirements()
mocked_function.assert_called_once_with(
"poetry export -f requirements.txt > requirements.txt"
)

0 comments on commit f814312

Please sign in to comment.