Skip to content

Commit ba23b88

Browse files
committed
Add unit test for jobserv schema validation
Signed-off-by: Andy Doan <andy@foundries.io>
1 parent 88c4b56 commit ba23b88

File tree

3 files changed

+28
-1
lines changed

3 files changed

+28
-1
lines changed

requirements-dev.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
requests==2.32.5
12
requests-mock==1.8.0
23
PyYAML==6.0.1
34
expandvars==0.6.5

tests/test_jobserv_schema.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Copyright (c) 2020 Foundries.io
2+
# SPDX-License-Identifier: BSD-3-Clause
3+
4+
import os
5+
import sys
6+
import unittest
7+
8+
import requests
9+
import yaml
10+
11+
12+
class JobservSchemaTest(unittest.TestCase):
13+
def test_schema(self):
14+
here = os.path.abspath(__file__)
15+
root = os.path.dirname(os.path.dirname(here))
16+
17+
paths = ("lmp/jobserv.yml", "factory-containers/jobserv.yml")
18+
for p in paths:
19+
with open(os.path.join(root, p)) as f:
20+
data = yaml.safe_load(f)
21+
r = requests.post("https://api.foundries.io/simulator-validate", json=data)
22+
if r.status_code != 200:
23+
try:
24+
sys.exit(r.json()['message'])
25+
except Exception:
26+
sys.exit(r.text)

unit-test.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/bin/sh -e
1+
#!/bin/bash -e
22

33
VENV_DIR=$(mktemp -d -p $PWD)
44
python3 -m venv "${VENV_DIR}"

0 commit comments

Comments
 (0)