-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_tutorial.py
More file actions
38 lines (34 loc) · 1.42 KB
/
test_tutorial.py
File metadata and controls
38 lines (34 loc) · 1.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import pytest
import os
import re
import glob
import requests
import subprocess
from pathlib import Path
cwd = os.getcwd()
repo = "https://soya.ownyourdata.eu"
playgrond = "https://playground.data-container.net"
# ensure SOyA Repo and Playground are available
def test_repos():
response = requests.get(repo + "/api/active")
assert response.status_code == 200
response = requests.get(playgrond + "/api/active")
assert response.status_code == 200
# Tutorial tests with some input and jsonld output
@pytest.mark.parametrize('input', ["person_simple", "employee", "foaf_person", "rest_api"])
def test_tutorial01(fp, input):
fp.allow_unregistered(True)
cmd = "curl -s https://playground.data-container.net/" + input + " | jq -r .yml | soya init"
process = subprocess.run(cmd, shell=True, capture_output=True, text=True)
assert process.returncode == 0
assert process.stdout.strip() == Path(cwd+"/examples/"+input+".jsonld").read_text().strip()
# Tutorial tests for overlays
@pytest.mark.parametrize('input', glob.glob(cwd+'/examples/overlay_*.jsonld'))
def test_tutorial02(fp, input):
fp.allow_unregistered(True)
m = re.search('overlay_(.+?).jsonld', input)
op = m.group(1)
cmd = "soya template " + op + " | soya init"
process = subprocess.run(cmd, shell=True, capture_output=True, text=True)
assert process.returncode == 0
assert process.stdout.strip() == Path(input).read_text().strip()