forked from michaeltryby/nrtest
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_config.py
92 lines (68 loc) · 1.96 KB
/
test_config.py
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
test_config
----------------------------------
Tests for input validation of tests and apps.
"""
import unittest
from nrtest import Application, Test
test_execution = {
'name': 'test',
'version': 1.0,
'args': ['config.txt'],
}
test_comparison = {
'name': 'test',
'version': 1.0,
'description': None,
'output_files': {'output.txt': 'default'},
'passed': True,
'error_msg': None,
}
app_execution = {
'name': 'app',
'version': 1.0,
'exe': 'cat',
}
app_comparison = {
'name': 'app',
'version': 1.0,
'description': None,
}
class TestExecuteTest(unittest.TestCase):
def setUp(self):
self.constructor = Test.for_execution
self.data = test_execution.copy()
def test_required(self):
self.constructor(self.data)
def test_unknown_field(self):
self.data['unknown'] = 'value'
with self.assertRaises(ValueError):
self.constructor(self.data)
def test_missing_field(self):
del self.data['name']
with self.assertRaises(ValueError):
self.constructor(self.data)
class TestCompareTest(TestExecuteTest):
def setUp(self):
self.constructor = Test.for_comparison
self.data = test_comparison.copy()
class TestExecuteApp(TestExecuteTest):
def setUp(self):
self.constructor = Application.for_execution
self.data = app_execution.copy()
class TestCompareApp(TestExecuteTest):
def setUp(self):
self.constructor = Application.for_comparison
self.data = app_comparison.copy()
class TestConversion(unittest.TestCase):
def test_convert_test(self):
test = Test.for_execution(test_execution)
Test.for_comparison(test.skim())
def test_convert_app(self):
app = Application.for_execution(app_execution)
Application.for_comparison(app.skim())
if __name__ == '__main__':
import sys
sys.exit(unittest.main())