Skip to content

Commit

Permalink
Merge branch 'master' of github.com:rdmorganiser/rdmo-catalog
Browse files Browse the repository at this point in the history
  • Loading branch information
jochenklar committed Aug 24, 2021
2 parents 4303d9b + 3985f67 commit e9fdbe5
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 0 deletions.
23 changes: 23 additions & 0 deletions .github/workflows/tests.yaml
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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@
*.tmp

__pycache__/
env/
tmp/
csv/
json/
env/


.on-save.json
44 changes: 44 additions & 0 deletions tests/test_xml.py
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

0 comments on commit e9fdbe5

Please sign in to comment.