Skip to content

Commit 6a46dbc

Browse files
committed
Add a test
1 parent d8b9cda commit 6a46dbc

File tree

5 files changed

+43
-11
lines changed

5 files changed

+43
-11
lines changed

example_graphs/example.json example_workflows/example.json

+3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{
2+
"name": "Example workflow",
23
"external_objects" : [
34
"example-object"
45
],
@@ -7,6 +8,7 @@
78
"registers" : 3,
89
"tasks" : [
910
{
11+
"name": "Example script",
1012
"input_registers" : [
1113
1
1214
],
@@ -19,6 +21,7 @@
1921
"type" : "script"
2022
},
2123
{
24+
"name": "Example execution",
2225
"exclusive" : true,
2326
"filesystems" : [
2427
{

example_graphs/run.json example_workflows/run.json

+23-11
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{
2+
"name": "Run the tests and grade the results",
23
"external_objects": [
34
"abc0a.in",
45
"abc0b.in",
@@ -35,7 +36,7 @@
3536
}
3637
],
3738
"hard_time_limit": 2137,
38-
"mount_namespace": [
39+
"mount_namespaces": [
3940
{
4041
"mountpoints": [
4142
{
@@ -67,6 +68,7 @@
6768
"/exe",
6869
"</in"
6970
],
71+
"environment": [],
7072
"image" : "/exe",
7173
"mount_namespace" : 0,
7274
"pid_namespace" : 0,
@@ -105,7 +107,7 @@
105107
}
106108
],
107109
"hard_time_limit": 2137,
108-
"mount_namespace": [
110+
"mount_namespaces": [
109111
{
110112
"mountpoints": [
111113
{
@@ -137,6 +139,7 @@
137139
"/exe",
138140
"</in"
139141
],
142+
"environment": [],
140143
"image" : "/exe",
141144
"mount_namespace" : 0,
142145
"pid_namespace" : 0,
@@ -175,7 +178,7 @@
175178
}
176179
],
177180
"hard_time_limit": 2137,
178-
"mount_namespace": [
181+
"mount_namespaces": [
179182
{
180183
"mountpoints": [
181184
{
@@ -207,6 +210,7 @@
207210
"/exe",
208211
"</in"
209212
],
213+
"environment": [],
210214
"image" : "/exe",
211215
"mount_namespace" : 0,
212216
"pid_namespace" : 0,
@@ -245,7 +249,7 @@
245249
}
246250
],
247251
"hard_time_limit": 2137,
248-
"mount_namespace": [
252+
"mount_namespaces": [
249253
{
250254
"mountpoints": [
251255
{
@@ -277,6 +281,7 @@
277281
"/exe",
278282
"</in"
279283
],
284+
"environment": [],
280285
"image" : "/exe",
281286
"mount_namespace" : 0,
282287
"pid_namespace" : 0,
@@ -315,7 +320,7 @@
315320
}
316321
],
317322
"hard_time_limit": 2137,
318-
"mount_namespace": [
323+
"mount_namespaces": [
319324
{
320325
"mountpoints": [
321326
{
@@ -347,6 +352,7 @@
347352
"/exe",
348353
"</in"
349354
],
355+
"environment": [],
350356
"image" : "/exe",
351357
"mount_namespace" : 0,
352358
"pid_namespace" : 0,
@@ -389,7 +395,7 @@
389395
}
390396
],
391397
"hard_time_limit": 2137,
392-
"mount_namespace": [
398+
"mount_namespaces": [
393399
{
394400
"mountpoints": [
395401
{
@@ -434,6 +440,7 @@
434440
"/out",
435441
"wzo_out"
436442
],
443+
"environment": [],
437444
"image" : "/chk",
438445
"mount_namespace" : 0,
439446
"pid_namespace" : 0,
@@ -476,7 +483,7 @@
476483
}
477484
],
478485
"hard_time_limit": 2137,
479-
"mount_namespace": [
486+
"mount_namespaces": [
480487
{
481488
"mountpoints": [
482489
{
@@ -521,6 +528,7 @@
521528
"/out",
522529
"wzo_out"
523530
],
531+
"environment": [],
524532
"image" : "/chk",
525533
"mount_namespace" : 0,
526534
"pid_namespace" : 0,
@@ -563,7 +571,7 @@
563571
}
564572
],
565573
"hard_time_limit": 2137,
566-
"mount_namespace": [
574+
"mount_namespaces": [
567575
{
568576
"mountpoints": [
569577
{
@@ -608,6 +616,7 @@
608616
"/out",
609617
"wzo_out"
610618
],
619+
"environment": [],
611620
"image" : "/chk",
612621
"mount_namespace" : 0,
613622
"pid_namespace" : 0,
@@ -650,7 +659,7 @@
650659
}
651660
],
652661
"hard_time_limit": 2137,
653-
"mount_namespace": [
662+
"mount_namespaces": [
654663
{
655664
"mountpoints": [
656665
{
@@ -695,6 +704,7 @@
695704
"/out",
696705
"wzo_out"
697706
],
707+
"environment": [],
698708
"image" : "/chk",
699709
"mount_namespace" : 0,
700710
"pid_namespace" : 0,
@@ -737,7 +747,7 @@
737747
}
738748
],
739749
"hard_time_limit": 2137,
740-
"mount_namespace": [
750+
"mount_namespaces": [
741751
{
742752
"mountpoints": [
743753
{
@@ -782,6 +792,7 @@
782792
"/out",
783793
"wzo_out"
784794
],
795+
"environment": [],
785796
"image" : "/chk",
786797
"mount_namespace" : 0,
787798
"pid_namespace" : 0,
@@ -855,7 +866,8 @@
855866
"name": "Grade group 1",
856867
"reactive": true,
857868
"input_registers": [13, 14],
858-
"output_registers": [17]
869+
"output_registers": [17],
870+
"script": "<PLACEHOLDER>"
859871
},
860872
{
861873
"type": "script",

setup.cfg

+1
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ tests =
3232
pytest
3333
pytest-cov
3434
pytest-xdist
35+
deepdiff
3536
django_tests =
3637
pytest-django
3738
django =

tests/workflow/__init__.py

Whitespace-only changes.

tests/workflow/test_workflow.py

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import os
2+
import json
3+
from deepdiff import DeepDiff
4+
5+
from sio3pack.workflow import Workflow
6+
7+
8+
def test_workflow_parsing():
9+
workflows_dir = os.path.join(os.path.dirname(__file__), "..", "..", "example_workflows")
10+
for file in os.listdir(workflows_dir):
11+
if not os.path.splitext(file)[1] == ".json":
12+
continue
13+
print(f'Parsing {file}')
14+
data = json.load(open(os.path.join(workflows_dir, file)))
15+
workflow = Workflow.from_dict(data)
16+
assert workflow.to_dict() == data, f"Failed for {file}. Diff: {DeepDiff(data, workflow.to_dict())}"

0 commit comments

Comments
 (0)