| 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 | |
| 178 # create test attributes, test labels, and iterations | 176 # create test attributes, test labels, and iterations |
| 179 # like Noah's Ark, include two of each...just in case there's a bug with | 177 # like Noah's Ark, include two of each...just in case there's a bug with |
| 180 # multiple related items | 178 # multiple related items |
| 181 models.TestAttribute.objects.create(test=job1_test1, attribute='myattr', | 179 models.TestAttribute.objects.create(test=job1_test1, attribute='myattr', |
| 182 value='myval') | 180 value='myval') |
| 183 models.TestAttribute.objects.create(test=job1_test1, | 181 models.TestAttribute.objects.create(test=job1_test1, |
| 184 attribute='myattr2', value='myval2') | 182 attribute='myattr2', value='myval2') |
| 185 | 183 |
| 186 self._add_iteration_keyval('tko_iteration_attributes', test=job1_test1, | 184 self._add_iteration_keyval('tko_iteration_attributes', test=job1_test1, |
| 187 iteration=1, attribute='iattr', | 185 iteration=1, attribute='iattr', |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 244 self.assertEquals(test['attributes'], {'myattr': 'myval', | 242 self.assertEquals(test['attributes'], {'myattr': 'myval', |
| 245 'myattr2': 'myval2'}) | 243 'myattr2': 'myval2'}) |
| 246 self.assertEquals(test['iterations'], [{'attr': {'iattr': 'ival', | 244 self.assertEquals(test['iterations'], [{'attr': {'iattr': 'ival', |
| 247 'iattr2': 'ival2'}, | 245 'iattr2': 'ival2'}, |
| 248 'perf': {'iresult': 1, | 246 'perf': {'iresult': 1, |
| 249 'iresult2': 2}}, | 247 'iresult2': 2}}, |
| 250 {'attr': {}, | 248 {'attr': {}, |
| 251 'perf': {'iresult': 3, | 249 'perf': {'iresult': 3, |
| 252 'iresult2': 4}}]) | 250 'iresult2': 4}}]) |
| 253 self.assertEquals(test['labels'], ['testlabel1', 'testlabel2']) | 251 self.assertEquals(test['labels'], ['testlabel1', 'testlabel2']) |
| 254 self.assertEquals(test['job_keyvals'], {'keyval_key': 'keyval_value'}) | |
| 255 | 252 |
| 256 | 253 |
| 257 def test_test_attributes(self): | 254 def test_test_attributes(self): |
| 258 rpc_interface.set_test_attribute('foo', 'bar', test_name='mytest1') | 255 rpc_interface.set_test_attribute('foo', 'bar', test_name='mytest1') |
| 259 test = rpc_interface.get_detailed_test_views()[0] | 256 test = rpc_interface.get_detailed_test_views()[0] |
| 260 self.assertEquals(test['attributes'], {'foo': 'bar', | 257 self.assertEquals(test['attributes'], {'foo': 'bar', |
| 261 'myattr': 'myval', | 258 'myattr': 'myval', |
| 262 'myattr2': 'myval2'}) | 259 'myattr2': 'myval2'}) |
| 263 | 260 |
| 264 rpc_interface.set_test_attribute('foo', 'goo', test_name='mytest1') | 261 rpc_interface.set_test_attribute('foo', 'goo', test_name='mytest1') |
| (...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 601 'machine_label_hyphen-label', | 598 'machine_label_hyphen-label', |
| 602 'iteration_result_hyphen-result'], | 599 'iteration_result_hyphen-result'], |
| 603 test_attribute_fields=['hyphen-attr'], | 600 test_attribute_fields=['hyphen-attr'], |
| 604 test_label_fields=['hyphen-label'], | 601 test_label_fields=['hyphen-label'], |
| 605 machine_label_fields=['hyphen-label'], | 602 machine_label_fields=['hyphen-label'], |
| 606 iteration_result_fields=['hyphen-result']) | 603 iteration_result_fields=['hyphen-result']) |
| 607 | 604 |
| 608 | 605 |
| 609 if __name__ == '__main__': | 606 if __name__ == '__main__': |
| 610 unittest.main() | 607 unittest.main() |
| OLD | NEW |