diff options
Diffstat (limited to 'test/test_grep.py')
-rw-r--r-- | test/test_grep.py | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/test/test_grep.py b/test/test_grep.py new file mode 100644 index 00000000..a4c8d91c --- /dev/null +++ b/test/test_grep.py @@ -0,0 +1,40 @@ +#!/usr/bin/env python3 + +"""Test filtering statements.""" + +import argparse +import sys +import shlex +import subprocess +import tempfile + +DOCUMENT = """<urn:example:s> <urn:example:p> <urn:example:o> . +<urn:example:s> <urn:example:q> <urn:example:r> . +""" + +parser = argparse.ArgumentParser(description=__doc__) + +parser.add_argument("--serdi", default="./serdi", help="path to serdi") +parser.add_argument("--wrapper", default="", help="executable wrapper") + +args = parser.parse_args(sys.argv[1:]) +command = shlex.split(args.wrapper) + [ + args.serdi, + "-g", + "?s <urn:example:p> <urn:example:o> .", + "-s", + DOCUMENT, +] + +with tempfile.TemporaryFile() as out: + proc = subprocess.run( + command, + check=False, + encoding="utf-8", + input=DOCUMENT, + capture_output=True, + ) + + assert proc.returncode == 0 + assert len(proc.stderr) == 0 + assert proc.stdout == "<urn:example:s> <urn:example:p> <urn:example:o> .\n" |