Skip to main content

Example BuildingSync files and tools for writing and validating BuildingSync use cases as schematron files.

Project description

testsuite

PyPI version

example workflow

A tool for writing and validating BuildingSync use cases as Schematron files. See the BuildingSync use-cases repository for current Schematron and example files for particular use cases.

Command line validation

Setup

Install from pypi

pip install testsuite

Install from source

Poetry is required to install testsuite.

# Copy repo
git clone https://github.com/BuildingSync/TestSuite.git

# install the package
cd TestSuite
poetry install

# Test that it works, you should see a message describing the usage
poetry run testsuite

Usage

Python

from testsuite.validate_sch import validate_schematron

# run basic validation
# returns an array of testsuite.validate_sch.Failures
failures = validate_schematron('my_schematron.sch', 'my_xml.xml')

# save the svrl result file
failures = validate_schematron('my_schematron.sch', 'my_xml.xml', result_path='validation_result.svrl')

# run a specific phase in schematron
failures = validate_schematron('my_schematron.sch', 'my_xml.xml', phase='MyPhaseID')

# report unfired rules as errors
failures = validate_schematron('my_schematron.sch', 'my_xml.xml', strict_context=True)

# fetch a file from the use-cases repo and use it for validation
import urllib.request
schematron_url = 'https://raw.githubusercontent.com/BuildingSync/use-cases/main/SEED/schematron/SEED-1.0.0.sch'
schematron_filename = 'local_schematron.sch'
urllib.request.urlretrieve(schematron_url, filename=schematron_filename)
failures = validate_schematron(schematron_filename, 'my_xml.xml')

CLI

testsuite validate my_schematron.sch my_xml.xml

# see all options
testsuite validate --help

Development

Generate Schematron

First create a CSV file that meets the required structure:

phase title,phase see,pattern title,pattern see,rule title,rule context,assert test,assert description,assert severity,notes

See the CSV files in this repo for examples.

Hierarchy is implied by the lack of text in a column. If no phase data is added to a row, it's considered to be the same phase as the row above. If no pattern data is present, it's assumed to be the same pattern as above. If no rule context is given, it's assumed to be the same as the one above.

The generator expects a "exemplary" xml file which should pass the validation. This is used to make sure all rules are applied (schematron will skip rules if the rule context doesn't match or if it only matches nodes that have already been matched within that pattern). If no exemplary file is provided no rule context checks will be made.

poetry run testsuite generate path_to_csv [path_to_exemplary_xml]

Testing

poetry run tox -e python

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

testsuite-0.1.3.tar.gz (14.4 kB view details)

Uploaded Source

Built Distribution

testsuite-0.1.3-py3-none-any.whl (22.2 kB view details)

Uploaded Python 3

File details

Details for the file testsuite-0.1.3.tar.gz.

File metadata

  • Download URL: testsuite-0.1.3.tar.gz
  • Upload date:
  • Size: 14.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.2.2 CPython/3.11.0 Darwin/21.6.0

File hashes

Hashes for testsuite-0.1.3.tar.gz
Algorithm Hash digest
SHA256 3ce73eb62aa8d31fb4a11a9264941e2569625b4904dc18978768e273d2b51334
MD5 94c80029e1caa67734ad14946da4523b
BLAKE2b-256 29cb2efdad3eadbbb869b0d5b6e01ba7f3de606b3b743c3f9855634e2896bdac

See more details on using hashes here.

File details

Details for the file testsuite-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: testsuite-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 22.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.2.2 CPython/3.11.0 Darwin/21.6.0

File hashes

Hashes for testsuite-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 3d2d131afbbfadcc290ac090a3649e0aa828dfeeb5343671d4e2d852752f83c7
MD5 8c87453ea69ceab57cd6414d1530447a
BLAKE2b-256 97cdf3d404efc78eabae7e9f38464799d9352e19358e3999e2792d1073529390

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page