Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

fix for possibility of a case selection for suite where cases exist e…

…ithout a case version.
  • Loading branch information...
commit 807261b05f53e998a82d4b3efea9b93536b2bfa3 1 parent 4ec90a8
@camd camd authored
View
21 moztrap/model/library/api.py
@@ -74,7 +74,12 @@ class CaseResource(MTResource):
Filterable by suites and product fields.
"""
- suites = fields.ToManyField(SuiteResource, "suites", readonly=True)
+ suites = fields.ToManyField(
+ SuiteResource,
+ "suites",
+ readonly=True,
+ null=True,
+ )
product = fields.ForeignKey(ProductResource, "product")
class Meta(MTResource.Meta):
@@ -328,11 +333,14 @@ class CaseSelectionResource(BaseSelectionResource):
),
related_name="versions",
full=True,
+ null=True,
)
- suites = fields.ToManyField(SuiteResource, "suites")
+ suites = fields.ToManyField(SuiteResource, "suites", null=True)
class Meta:
- queryset = Case.objects.all().select_related(
+ # versions=None exclude is just in case a ``case`` exists with no
+ # case versions.
+ queryset = Case.objects.all().exclude(versions=None).select_related(
"product",
).prefetch_related(
"versions__tags",
@@ -370,7 +378,12 @@ class CaseVersionSelectionResource(BaseSelectionResource):
productversion = fields.ForeignKey(
ProductVersionResource, "productversion", full=True)
tags = fields.ToManyField(TagResource, "tags", full=True)
- created_by = fields.ForeignKey(UserResource, "created_by", full=True, null=True)
+ created_by = fields.ForeignKey(
+ UserResource,
+ "created_by",
+ full=True,
+ null=True,
+ )
class Meta:
queryset = CaseVersion.objects.all().select_related(
View
16 tests/model/library/api/test_case_resource.py
@@ -299,3 +299,19 @@ def test_included_for_one_included_one_not(self):
self.included_param,
exp_objects=exp_objects,
)
+
+
+ def test_case_without_version(self):
+ """Get a list of available cases, skip ones without versions"""
+
+ # create a case with no version
+ self.F.CaseFactory()
+
+ data = self._setup_for_one_included_one_not()
+ exp_objects = [self.get_exp_obj(data["cv2"])]
+
+ self._do_test(
+ data["s"].id,
+ self.available_param,
+ exp_objects=exp_objects,
+ )
Please sign in to comment.
Something went wrong with that request. Please try again.