OLD | NEW |
1 #!/usr/bin/python | 1 #!/usr/bin/python |
2 | 2 |
3 import re, unittest | 3 import re, unittest |
4 import common | 4 import common |
5 from autotest_lib.frontend import setup_django_environment | 5 from autotest_lib.frontend import setup_django_environment |
6 from autotest_lib.frontend import setup_test_environment | 6 from autotest_lib.frontend import setup_test_environment |
7 from autotest_lib.client.common_lib.test_utils import mock | 7 from autotest_lib.client.common_lib.test_utils import mock |
8 from django.db import connection | 8 from django.db import connection |
9 from autotest_lib.frontend.tko import models, rpc_interface | 9 from autotest_lib.frontend.tko import models, rpc_interface |
10 | 10 |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
166 self.first_test = job1_test1 | 166 self.first_test = job1_test1 |
167 job1_test2 = models.Test.objects.create(job=job1, test='mytest2', | 167 job1_test2 = models.Test.objects.create(job=job1, test='mytest2', |
168 kernel=kernel1, | 168 kernel=kernel1, |
169 status=failed_status, | 169 status=failed_status, |
170 machine=machine) | 170 machine=machine) |
171 job2_test1 = models.Test.objects.create(job=job2, test='kernbench', | 171 job2_test1 = models.Test.objects.create(job=job2, test='kernbench', |
172 kernel=kernel2, | 172 kernel=kernel2, |
173 status=good_status, | 173 status=good_status, |
174 machine=machine) | 174 machine=machine) |
175 | 175 |
| 176 job1.jobkeyval_set.create(key='keyval_key', value='keyval_value') |
| 177 |
176 # create test attributes, test labels, and iterations | 178 # create test attributes, test labels, and iterations |
177 # like Noah's Ark, include two of each...just in case there's a bug with | 179 # like Noah's Ark, include two of each...just in case there's a bug with |
178 # multiple related items | 180 # multiple related items |
179 models.TestAttribute.objects.create(test=job1_test1, attribute='myattr', | 181 models.TestAttribute.objects.create(test=job1_test1, attribute='myattr', |
180 value='myval') | 182 value='myval') |
181 models.TestAttribute.objects.create(test=job1_test1, | 183 models.TestAttribute.objects.create(test=job1_test1, |
182 attribute='myattr2', value='myval2') | 184 attribute='myattr2', value='myval2') |
183 | 185 |
184 self._add_iteration_keyval('tko_iteration_attributes', test=job1_test1, | 186 self._add_iteration_keyval('tko_iteration_attributes', test=job1_test1, |
185 iteration=1, attribute='iattr', | 187 iteration=1, attribute='iattr', |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
242 self.assertEquals(test['attributes'], {'myattr': 'myval', | 244 self.assertEquals(test['attributes'], {'myattr': 'myval', |
243 'myattr2': 'myval2'}) | 245 'myattr2': 'myval2'}) |
244 self.assertEquals(test['iterations'], [{'attr': {'iattr': 'ival', | 246 self.assertEquals(test['iterations'], [{'attr': {'iattr': 'ival', |
245 'iattr2': 'ival2'}, | 247 'iattr2': 'ival2'}, |
246 'perf': {'iresult': 1, | 248 'perf': {'iresult': 1, |
247 'iresult2': 2}}, | 249 'iresult2': 2}}, |
248 {'attr': {}, | 250 {'attr': {}, |
249 'perf': {'iresult': 3, | 251 'perf': {'iresult': 3, |
250 'iresult2': 4}}]) | 252 'iresult2': 4}}]) |
251 self.assertEquals(test['labels'], ['testlabel1', 'testlabel2']) | 253 self.assertEquals(test['labels'], ['testlabel1', 'testlabel2']) |
| 254 self.assertEquals(test['job_keyvals'], {'keyval_key': 'keyval_value'}) |
252 | 255 |
253 | 256 |
254 def test_test_attributes(self): | 257 def test_test_attributes(self): |
255 rpc_interface.set_test_attribute('foo', 'bar', test_name='mytest1') | 258 rpc_interface.set_test_attribute('foo', 'bar', test_name='mytest1') |
256 test = rpc_interface.get_detailed_test_views()[0] | 259 test = rpc_interface.get_detailed_test_views()[0] |
257 self.assertEquals(test['attributes'], {'foo': 'bar', | 260 self.assertEquals(test['attributes'], {'foo': 'bar', |
258 'myattr': 'myval', | 261 'myattr': 'myval', |
259 'myattr2': 'myval2'}) | 262 'myattr2': 'myval2'}) |
260 | 263 |
261 rpc_interface.set_test_attribute('foo', 'goo', test_name='mytest1') | 264 rpc_interface.set_test_attribute('foo', 'goo', test_name='mytest1') |
(...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
598 'machine_label_hyphen-label', | 601 'machine_label_hyphen-label', |
599 'iteration_result_hyphen-result'], | 602 'iteration_result_hyphen-result'], |
600 test_attribute_fields=['hyphen-attr'], | 603 test_attribute_fields=['hyphen-attr'], |
601 test_label_fields=['hyphen-label'], | 604 test_label_fields=['hyphen-label'], |
602 machine_label_fields=['hyphen-label'], | 605 machine_label_fields=['hyphen-label'], |
603 iteration_result_fields=['hyphen-result']) | 606 iteration_result_fields=['hyphen-result']) |
604 | 607 |
605 | 608 |
606 if __name__ == '__main__': | 609 if __name__ == '__main__': |
607 unittest.main() | 610 unittest.main() |
OLD | NEW |