1 from autotest_lib
.frontend
.shared
import query_lib
, resource_lib
2 from autotest_lib
.frontend
.tko
import models
4 class TestResult(resource_lib
.InstanceEntry
):
9 def add_query_selectors(cls
, query_processor
):
10 query_processor
.add_field_selector('afe_job_id',
11 field
='job__afe_job_id')
12 query_processor
.add_keyval_selector('has_keyval', models
.TestAttribute
,
17 def from_uri_args(cls
, request
, test_id
, **kwargs
):
18 return cls(request
, models
.Test
.objects
.get(pk
=test_id
))
22 return {'test_id': self
.instance
.pk
}
25 def short_representation(self
):
26 rep
= super(TestResult
, self
).short_representation()
27 rep
.update(id=self
.instance
.test_idx
,
28 test_name
=self
.instance
.test
,
29 status
=self
.instance
.status
.word
,
30 reason
=self
.instance
.reason
,
31 afe_job_id
=self
.instance
.job
.afe_job_id
,
36 def full_representation(self
):
37 rep
= super(TestResult
, self
).full_representation()
38 rep
['keyvals'] = dict((keyval
.attribute
, keyval
.value
)
40 in self
.instance
.testattribute_set
.all())
44 class TestResultCollection(resource_lib
.Collection
):
45 queryset
= models
.Test
.objects
.order_by('-test_idx')
46 entry_class
= TestResult
49 class ResourceDirectory(resource_lib
.Resource
):
50 _permitted_methods
= ('GET',)
52 def handle_request(self
):
55 'test_results': TestResultCollection(self
._request
).link(),
57 return self
._basic
_response
(result
)