3 # Copyright 2008 Google Inc. All Rights Reserved.
7 import unittest
, sys
, os
10 from autotest_lib
.cli
import cli_mock
, topic_common
, test
13 class test_list_unittest(cli_mock
.cli_unittest
):
14 values
= [{u
'description': u
'unknown',
15 u
'test_type': u
'Client',
16 u
'test_class': u
'Canned Test Sets',
17 u
'path': u
'client/tests/test0/control',
18 u
'synch_type': u
'Asynchronous',
21 u
'experimental': False},
22 {u
'description': u
'unknown',
23 u
'test_type': u
'Server',
24 u
'test_class': u
'Kernel',
25 u
'path': u
'server/tests/test1/control',
26 u
'synch_type': u
'Asynchronous',
29 u
'experimental': False},
30 {u
'description': u
'unknown',
31 u
'test_type': u
'Client',
32 u
'test_class': u
'Canned Test Sets',
33 u
'path': u
'client/tests/test2/control.readprofile',
34 u
'synch_type': u
'Asynchronous',
37 u
'experimental': False},
38 {u
'description': u
'unknown',
39 u
'test_type': u
'Server',
40 u
'test_class': u
'Canned Test Sets',
41 u
'path': u
'server/tests/test3/control',
42 u
'synch_type': u
'Asynchronous',
45 u
'experimental': False},
46 {u
'description': u
'Random stuff to check that things are ok',
47 u
'test_type': u
'Client',
48 u
'test_class': u
'Hardware',
49 u
'path': u
'client/tests/test4/control.export',
50 u
'synch_type': u
'Asynchronous',
53 u
'experimental': True}]
56 def test_test_list_tests_default(self
):
57 self
.run_cmd(argv
=['atest', 'test', 'list'],
58 rpcs
=[('get_tests', {'experimental': False},
60 out_words_ok
=['test0', 'test1', 'test2',
62 out_words_no
=['Random', 'control.export'])
65 def test_test_list_tests_all(self
):
66 self
.run_cmd(argv
=['atest', 'test', 'list', '--all'],
67 rpcs
=[('get_tests', {},
69 out_words_ok
=['test0', 'test1', 'test2',
71 out_words_no
=['Random', 'control.export'])
74 def test_test_list_tests_exp(self
):
75 self
.run_cmd(argv
=['atest', 'test', 'list', '--experimental'],
76 rpcs
=[('get_tests', {'experimental': True},
78 [{u
'description': u
'Random stuff',
79 u
'test_type': u
'Client',
80 u
'test_class': u
'Hardware',
81 u
'path': u
'client/tests/test4/control.export',
82 u
'synch_type': u
'Asynchronous',
85 u
'experimental': True}])],
86 out_words_ok
=['test4'],
87 out_words_no
=['Random', 'control.export'])
90 def test_test_list_tests_select_one(self
):
91 filtered
= [val
for val
in self
.values
if val
['name'] in ['test3']]
92 self
.run_cmd(argv
=['atest', 'test', 'list', 'test3'],
93 rpcs
=[('get_tests', {'name__in': ['test3'],
94 'experimental': False},
96 out_words_ok
=['test3'],
97 out_words_no
=['test0', 'test1', 'test2', 'test4',
101 def test_test_list_tests_select_two(self
):
102 filtered
= [val
for val
in self
.values
103 if val
['name'] in ['test3', 'test1']]
104 self
.run_cmd(argv
=['atest', 'test', 'list', 'test3,test1'],
105 rpcs
=[('get_tests', {'name__in': ['test1', 'test3'],
106 'experimental': False},
108 out_words_ok
=['test3', 'test1', 'Server'],
109 out_words_no
=['test0', 'test2', 'test4',
110 'unknown', 'Client'])
113 def test_test_list_tests_select_two_space(self
):
114 filtered
= [val
for val
in self
.values
115 if val
['name'] in ['test3', 'test1']]
116 self
.run_cmd(argv
=['atest', 'test', 'list', 'test3', 'test1'],
117 rpcs
=[('get_tests', {'name__in': ['test1', 'test3'],
118 'experimental': False},
120 out_words_ok
=['test3', 'test1', 'Server'],
121 out_words_no
=['test0', 'test2', 'test4',
122 'unknown', 'Client'])
125 def test_test_list_tests_all_verbose(self
):
126 self
.run_cmd(argv
=['atest', 'test', 'list', '-v'],
127 rpcs
=[('get_tests', {'experimental': False},
129 out_words_ok
=['test0', 'test1', 'test2',
130 'test3', 'test4', 'client/tests',
132 out_words_no
=['Random'])
135 def test_test_list_tests_all_desc(self
):
136 self
.run_cmd(argv
=['atest', 'test', 'list', '-d'],
137 rpcs
=[('get_tests', {'experimental': False},
139 out_words_ok
=['test0', 'test1', 'test2',
140 'test3', 'test4', 'unknown', 'Random'],
141 out_words_no
=['client/tests', 'server/tests'])
144 def test_test_list_tests_all_desc_verbose(self
):
145 self
.run_cmd(argv
=['atest', 'test', 'list', '-d', '-v'],
146 rpcs
=[('get_tests', {'experimental': False},
148 out_words_ok
=['test0', 'test1', 'test2',
149 'test3', 'test4', 'client/tests',
150 'server/tests', 'unknown', 'Random' ])
153 if __name__
== '__main__':