-
Notifications
You must be signed in to change notification settings - Fork 239
Expand file tree
/
Copy pathtest_systemextensionsctl.py
More file actions
82 lines (67 loc) · 2.84 KB
/
test_systemextensionsctl.py
File metadata and controls
82 lines (67 loc) · 2.84 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
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
import os
import json
import unittest
import jc.parsers.systemextensionsctl
THIS_DIR = os.path.dirname(os.path.abspath(__file__))
class MyTests(unittest.TestCase):
# Input data from fixtures
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/generic/systemextensionsctl.out'), 'r', encoding='utf-8') as f:
systemextensionsctl_output = f.read()
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/generic/systemextensionsctl-no-extensions.out'), 'r', encoding='utf-8') as f:
systemextensionsctl_no_extensions_output = f.read()
# Expected output data from fixtures
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/generic/systemextensionsctl.json'), 'r', encoding='utf-8') as f:
systemextensionsctl_expected = json.loads(f.read())
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/generic/systemextensionsctl-no-extensions.json'), 'r', encoding='utf-8') as f:
systemextensionsctl_no_extensions_expected = json.loads(f.read())
def test_systemextensionsctl(self):
"""
Test 'systemextensionsctl list' with placeholder data
"""
self.assertEqual(
jc.parsers.systemextensionsctl.parse(
self.systemextensionsctl_output, quiet=True),
self.systemextensionsctl_expected
)
def test_systemextensionsctl_empty(self):
"""
Test 'systemextensionsctl list' with empty input
"""
self.assertEqual(
jc.parsers.systemextensionsctl.parse(
'', quiet=True),
{}
)
def test_systemextensionsctl_no_extensions(self):
"""
Test 'systemextensionsctl list' with no extensions
"""
self.assertEqual(
jc.parsers.systemextensionsctl.parse(
self.systemextensionsctl_no_extensions_output, quiet=True),
self.systemextensionsctl_no_extensions_expected
)
def test_systemextensionsctl_nodata(self):
"""
Test 'systemextensionsctl list' with no data
"""
self.assertEqual(jc.parsers.systemextensionsctl.parse('', quiet=True), {})
def test_systemextensionsctl_incorrect_format(self):
"""
Test 'systemextensionsctl list' with incorrect format
"""
incorrect_data = 'This is not the correct format.'
self.assertEqual(
jc.parsers.systemextensionsctl.parse(incorrect_data, quiet=True), {}
)
def test_systemextensionsctl_trailing_newline(self):
"""
Test 'systemextensionsctl list' with trailing newline
"""
cmd_output = self.systemextensionsctl_output + '\n'
self.assertEqual(
jc.parsers.systemextensionsctl.parse(cmd_output, quiet=True),
self.systemextensionsctl_expected
)
if __name__ == '__main__':
unittest.main()