Skip to content
This repository has been archived by the owner on Jan 19, 2022. It is now read-only.

Commit

Permalink
Merge branch '1.4.5.3' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
Cameron Dawson committed Apr 8, 2013
2 parents d65c140 + 807261b commit 6e39cc1
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 4 deletions.
21 changes: 17 additions & 4 deletions moztrap/model/library/api.py
Expand Up @@ -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):
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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(
Expand Down
16 changes: 16 additions & 0 deletions tests/model/library/api/test_case_resource.py
Expand Up @@ -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,
)

0 comments on commit 6e39cc1

Please sign in to comment.