-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of github.com:rdmorganiser/rdmo-catalog
- Loading branch information
Showing
3 changed files
with
69 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,23 @@ | ||
on: push | ||
|
||
name: Run tests | ||
|
||
jobs: | ||
tests: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
- name: Use Python 3.8 | ||
uses: actions/setup-python@v2 | ||
with: | ||
python-version: '3.8' | ||
|
||
- name: Install xmllint | ||
run: sudo apt-get install libxml2-utils | ||
|
||
- name: Install requirements | ||
run: pip install pytest | ||
|
||
- name: Run tests | ||
run: pytest |
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 |
---|---|---|
|
@@ -4,9 +4,11 @@ | |
*.tmp | ||
|
||
__pycache__/ | ||
env/ | ||
tmp/ | ||
csv/ | ||
json/ | ||
env/ | ||
|
||
|
||
.on-save.json |
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,44 @@ | ||
import os | ||
from pathlib import Path | ||
from subprocess import check_call | ||
import xml.etree.ElementTree as ET | ||
|
||
import pytest | ||
|
||
PATHS = ['rdmorganiser', 'shared'] | ||
TAGS = [ | ||
'condition', | ||
'attribute', | ||
'optionset', | ||
'option', | ||
'catalog', | ||
'section', | ||
'questionset', | ||
'question', | ||
'task', | ||
'view' | ||
] | ||
|
||
|
||
def walk_xml_files(): | ||
for path in PATHS: | ||
for root, dirs, files in os.walk(path): | ||
for file in files: | ||
file_path = Path(root) / file | ||
if file_path.suffix == '.xml': | ||
yield file_path | ||
|
||
|
||
@pytest.mark.parametrize('xml_file', walk_xml_files()) | ||
def test_xmllint(xml_file): | ||
check_call(['xmllint', '--noout', xml_file]) | ||
|
||
|
||
@pytest.mark.parametrize('xml_file', walk_xml_files()) | ||
def test_tags(xml_file): | ||
tree = ET.parse(xml_file) | ||
root = tree.getroot() | ||
assert root.tag == 'rdmo' | ||
|
||
for child in root: | ||
assert child.tag in TAGS |