Skip to content

Commit

Permalink
Merge pull request #205 from Open-Telecoms-Data/2022-11-12-add-tests
Browse files Browse the repository at this point in the history
actions: Add pytest and first tests
  • Loading branch information
odscjames committed Dec 1, 2022
2 parents 4bf83d5 + e8baf60 commit 52d956f
Show file tree
Hide file tree
Showing 5 changed files with 77 additions and 9 deletions.
19 changes: 19 additions & 0 deletions .github/workflows/run-tests.yml
@@ -0,0 +1,19 @@
name: Run all tests
on: [push, pull_request]

jobs:
tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Setup python
uses: actions/setup-python@v2
with:
python-version: 3.9
architecture: x64
- uses: actions/cache@v1
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
- run: pip install -r requirements.txt
- run: pytest tests
4 changes: 3 additions & 1 deletion requirements.in
Expand Up @@ -12,4 +12,6 @@ PyGithub
ocdskit
sphinx-design
libcoveofds
flattentool
flattentool
pytest
jscc
41 changes: 33 additions & 8 deletions requirements.txt
@@ -1,6 +1,6 @@
#
# This file is autogenerated by pip-compile with python 3.9
# To update, run:
# This file is autogenerated by pip-compile with Python 3.9
# by the following command:
#
# pip-compile requirements.in
#
Expand All @@ -12,6 +12,7 @@ attrs==22.1.0
# via
# cattrs
# jsonschema
# pytest
# requests-cache
babel==2.10.3
# via
Expand Down Expand Up @@ -51,8 +52,10 @@ docutils==0.17.1
et-xmlfile==1.1.0
# via openpyxl
exceptiongroup==1.0.0rc9
# via cattrs
flattentool==0.18.1
# via
# cattrs
# pytest
flattentool==0.19.0
# via -r requirements.in
gitdb==4.0.9
# via gitpython
Expand All @@ -68,29 +71,37 @@ imagesize==1.4.1
# via sphinx
importlib-metadata==4.12.0
# via sphinx
iniconfig==1.1.1
# via pytest
jinja2==3.1.2
# via
# myst-parser
# sphinx
jscc==0.1.0
# via -r requirements.in
json-merge-patch==0.2
# via
# jscc
# libcoveofds
# ocdsextensionregistry
jsonpointer==2.3
# via
# sphinxcontrib-opendataservices
# sphinxcontrib-opendataservices-jsonschema
jsonref==0.2
jsonref==1.0.1
# via
# -r requirements.in
# flattentool
# jscc
# libcoveofds
# ocdsextensionregistry
# ocdskit
# ocdsmerge
# sphinxcontrib-opendataservices-jsonschema
jsonschema==4.17.3
# via libcoveofds
# via
# jscc
# libcoveofds
libcoveofds==0.5.0
# via -r requirements.in
livereload==2.6.3
Expand Down Expand Up @@ -123,11 +134,15 @@ odfpy==1.4.1
openpyxl==3.0.10
# via flattentool
packaging==21.3
# via sphinx
# via
# pytest
# sphinx
persistent==4.9.1
# via
# btrees
# zodb
pluggy==1.0.0
# via pytest
pyairtable==1.3.0
# via -r requirements.in
pycparser==2.21
Expand All @@ -144,6 +159,8 @@ pyparsing==3.0.9
# via packaging
pyrsistent==0.19.2
# via jsonschema
pytest==7.2.0
# via -r requirements.in
python-slugify==4.0.1
# via transifex-client
pytz==2022.1
Expand All @@ -154,6 +171,7 @@ pyyaml==6.0
# via myst-parser
requests==2.28.1
# via
# jscc
# libcoveofds
# ocdsextensionregistry
# ocdsmerge
Expand All @@ -164,11 +182,16 @@ requests==2.28.1
# transifex-client
requests-cache==0.9.6
# via ocdsextensionregistry
rfc3339-validator==0.1.4
# via jscc
rfc3986-validator==0.1.1
# via jscc
schema==0.7.5
# via flattentool
six==1.16.0
# via
# livereload
# rfc3339-validator
# transifex-client
# url-normalize
# zodb
Expand Down Expand Up @@ -203,7 +226,7 @@ sphinxcontrib-jsmath==1.0.1
# via sphinx
sphinxcontrib-opendataservices==0.5.0
# via -r requirements.in
sphinxcontrib-opendataservices-jsonschema==0.5.0
sphinxcontrib-opendataservices-jsonschema==0.5.1
# via
# -r requirements.in
# sphinxcontrib-opendataservices
Expand All @@ -213,6 +236,8 @@ sphinxcontrib-serializinghtml==1.1.5
# via sphinx
text-unidecode==1.3
# via python-slugify
tomli==2.0.1
# via pytest
tornado==6.2
# via livereload
transaction==3.0.1
Expand Down
8 changes: 8 additions & 0 deletions tests/test_csv.py
@@ -0,0 +1,8 @@
from jscc.testing.checks import get_invalid_csv_files
from jscc.testing.util import warn_and_assert


def test_csv_valid():
warn_and_assert(get_invalid_csv_files(), '{0} is not valid CSV: {1}',
'CSV files are invalid. See warnings below.')

14 changes: 14 additions & 0 deletions tests/test_json.py
@@ -0,0 +1,14 @@
from jscc.testing.checks import get_empty_files, get_misindented_files, get_invalid_json_files
from jscc.testing.util import warn_and_assert


def test_empty():
empty_files_paths = [path for path in get_empty_files() if "src/" not in path[0]]
warn_and_assert(empty_files_paths, "{0} is empty, run: rm {0}", "Files are empty. See warnings below.")


def test_invalid_json():
warn_and_assert(
get_invalid_json_files(excluded=('.git', '.ve', '_static', 'build', 'fixtures', "_build")), "{0} is not valid JSON: {1}", "JSON files are invalid. See warnings below."
)

0 comments on commit 52d956f

Please sign in to comment.