Permalink
Browse files

filtering by description, fixed sorting by result unique to envs.

  • Loading branch information...
1 parent 3c994ca commit c2645b5a2677b0944f3b723cbbcab94126503251 @camd camd committed May 6, 2013
Showing with 30 additions and 1 deletion.
  1. +3 −0 moztrap/view/filters.py
  2. +2 −1 moztrap/view/runtests/views.py
  3. +25 −0 tests/view/runtests/test_views.py
View
@@ -97,6 +97,7 @@ class RunCaseVersionFilterSet(filters.FilterSet):
filters.KeywordExactFilter(
"id", lookup="caseversion__case__id", coerce=int),
filters.KeywordFilter("name", lookup="caseversion__name"),
+ filters.KeywordFilter("description", lookup="caseversion__description"),
filters.ModelFilter(
"tag",
lookup="caseversion__tags",
@@ -140,6 +141,7 @@ class RunTestsRunCaseVersionFilterSet(filters.FilterSet):
filters.KeywordExactFilter(
"id", lookup="caseversion__case__id", coerce=int),
filters.KeywordFilter("name", lookup="caseversion__name"),
+ filters.KeywordFilter("description", lookup="caseversion__description"),
filters.ModelFilter(
"tag",
lookup="caseversion__tags",
@@ -210,6 +212,7 @@ class CaseVersionFilterSet(filters.FilterSet):
filters.ChoicesFilter("status", choices=model.CaseVersion.STATUS),
cases.PrefixIDFilter("id"),
filters.KeywordFilter("name"),
+ filters.KeywordFilter("description"),
filters.ModelFilter(
"tag", lookup="tags", queryset=model.Tag.objects.all()),
filters.ModelFilter(
@@ -219,9 +219,10 @@ def run(request, run_id, env_id):
current_result_select = (
"SELECT status from execution_result as r "
"WHERE r.runcaseversion_id = execution_runcaseversion.id "
+ "AND r.environment_id = {0} "
"AND r.status in ('passed', 'invalidated', 'failed') "
"AND r.is_latest = 1 "
- "ORDER BY r.created_on DESC LIMIT 1")
+ "ORDER BY r.created_on DESC LIMIT 1".format(environment.id))
return TemplateResponse(
request,
@@ -460,6 +460,31 @@ def test_sort_by_status(self):
self.assertOrderInList(res, "t1", "t2", "t3", "t4")
+ def test_sort_by_status_env_specific(self):
+ """
+ Can sort by status. Specific to env in question.
+
+ If rcv has result for different env, it's ignored
+ """
+ user2 = self.F.UserFactory()
+ t1 = self.create_rcv(caseversion__name="t1")
+ t2 = self.create_rcv(caseversion__name="t2")
+ self.create_result(runcaseversion=t1, status="started")
+ self.create_result(runcaseversion=t2, status="failed", tester=user2)
+
+ # result for different env that should be ignored in sort
+ self.create_result(
+ runcaseversion=t1,
+ environment=self.envs[1],
+ status="passed",
+ )
+
+ res = self.get(
+ params={"sortfield": "current_result", "sortdirection": "asc"})
+
+ self.assertOrderInList(res, "t1", "t2")
+
+
def test_description(self):
"""Returns details HTML snippet for given caseversion"""

0 comments on commit c2645b5

Please sign in to comment.