forked from autotest/autotest
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_unittest.py
executable file
·150 lines (134 loc) · 6.51 KB
/
test_unittest.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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
#!/usr/bin/python
#
# Copyright 2008 Google Inc. All Rights Reserved.
"""Tests for test."""
import unittest
import sys
import os
try:
import autotest.common as common
except ImportError:
import common
from autotest.cli import cli_mock, topic_common, test
class test_list_unittest(cli_mock.cli_unittest):
values = [{u'description': u'unknown',
u'test_type': u'Client',
u'test_class': u'Canned Test Sets',
u'path': u'client/tests/test0/control',
u'synch_type': u'Asynchronous',
u'id': 138,
u'name': u'test0',
u'experimental': False},
{u'description': u'unknown',
u'test_type': u'Server',
u'test_class': u'Kernel',
u'path': u'server/tests/test1/control',
u'synch_type': u'Asynchronous',
u'id': 139,
u'name': u'test1',
u'experimental': False},
{u'description': u'unknown',
u'test_type': u'Client',
u'test_class': u'Canned Test Sets',
u'path': u'client/tests/test2/control.readprofile',
u'synch_type': u'Asynchronous',
u'id': 140,
u'name': u'test2',
u'experimental': False},
{u'description': u'unknown',
u'test_type': u'Server',
u'test_class': u'Canned Test Sets',
u'path': u'server/tests/test3/control',
u'synch_type': u'Asynchronous',
u'id': 142,
u'name': u'test3',
u'experimental': False},
{u'description': u'Random stuff to check that things are ok',
u'test_type': u'Client',
u'test_class': u'Hardware',
u'path': u'client/tests/test4/control.export',
u'synch_type': u'Asynchronous',
u'id': 143,
u'name': u'test4',
u'experimental': True}]
def test_test_list_tests_default(self):
self.run_cmd(argv=['atest', 'test', 'list'],
rpcs=[('get_tests', {'experimental': False},
True, self.values)],
out_words_ok=['test0', 'test1', 'test2',
'test3', 'test4'],
out_words_no=['Random', 'control.export'])
def test_test_list_tests_all(self):
self.run_cmd(argv=['atest', 'test', 'list', '--all'],
rpcs=[('get_tests', {},
True, self.values)],
out_words_ok=['test0', 'test1', 'test2',
'test3', 'test4'],
out_words_no=['Random', 'control.export'])
def test_test_list_tests_exp(self):
self.run_cmd(argv=['atest', 'test', 'list', '--experimental'],
rpcs=[('get_tests', {'experimental': True},
True,
[{u'description': u'Random stuff',
u'test_type': u'Client',
u'test_class': u'Hardware',
u'path': u'client/tests/test4/control.export',
u'synch_type': u'Asynchronous',
u'id': 143,
u'name': u'test4',
u'experimental': True}])],
out_words_ok=['test4'],
out_words_no=['Random', 'control.export'])
def test_test_list_tests_select_one(self):
filtered = [val for val in self.values if val['name'] in ['test3']]
self.run_cmd(argv=['atest', 'test', 'list', 'test3'],
rpcs=[('get_tests', {'name__in': ['test3'],
'experimental': False},
True, filtered)],
out_words_ok=['test3'],
out_words_no=['test0', 'test1', 'test2', 'test4',
'unknown'])
def test_test_list_tests_select_two(self):
filtered = [val for val in self.values
if val['name'] in ['test3', 'test1']]
self.run_cmd(argv=['atest', 'test', 'list', 'test3,test1'],
rpcs=[('get_tests', {'name__in': ['test1', 'test3'],
'experimental': False},
True, filtered)],
out_words_ok=['test3', 'test1', 'Server'],
out_words_no=['test0', 'test2', 'test4',
'unknown', 'Client'])
def test_test_list_tests_select_two_space(self):
filtered = [val for val in self.values
if val['name'] in ['test3', 'test1']]
self.run_cmd(argv=['atest', 'test', 'list', 'test3', 'test1'],
rpcs=[('get_tests', {'name__in': ['test1', 'test3'],
'experimental': False},
True, filtered)],
out_words_ok=['test3', 'test1', 'Server'],
out_words_no=['test0', 'test2', 'test4',
'unknown', 'Client'])
def test_test_list_tests_all_verbose(self):
self.run_cmd(argv=['atest', 'test', 'list', '-v'],
rpcs=[('get_tests', {'experimental': False},
True, self.values)],
out_words_ok=['test0', 'test1', 'test2',
'test3', 'test4', 'client/tests',
'server/tests'],
out_words_no=['Random'])
def test_test_list_tests_all_desc(self):
self.run_cmd(argv=['atest', 'test', 'list', '-d'],
rpcs=[('get_tests', {'experimental': False},
True, self.values)],
out_words_ok=['test0', 'test1', 'test2',
'test3', 'test4', 'unknown', 'Random'],
out_words_no=['client/tests', 'server/tests'])
def test_test_list_tests_all_desc_verbose(self):
self.run_cmd(argv=['atest', 'test', 'list', '-d', '-v'],
rpcs=[('get_tests', {'experimental': False},
True, self.values)],
out_words_ok=['test0', 'test1', 'test2',
'test3', 'test4', 'client/tests',
'server/tests', 'unknown', 'Random'])
if __name__ == '__main__':
unittest.main()