Permalink
Browse files

fixed tests for new suite case picker, and removed unnecessary code

  • Loading branch information...
camd committed Apr 2, 2013
1 parent 9956a24 commit cca98043b2904a5b55be4f226a8a57549f4cb48e
@@ -1,8 +1,8 @@
{{#items}}
<article class="selectitem" data-title="{{ name }}" data-product-id="{{ product_id }}">
- <input type="checkbox" name="bulk-select" value="{{ case_id }}" class="bulk-value" id="bulk-select-{{ case_id }}" {{ checked }}>
+ <input type="checkbox" name="bulk-select" value="{{ id }}" class="bulk-value" id="bulk-select-{{ id }}" {{ checked }}>
<div class="listitem itemhead bulk-item">
- <label for="bulk-select-{{ case_id }}" class="bulk-type" title="select or drag">bulk select {{ case_id }}</label>
+ <label for="bulk-select-{{ id }}" class="bulk-type" title="select or drag">bulk select {{ case_id }}</label>
<div class="name-tags">
<h5 class="title" title="{{ name }}">{{ name }}</h5>
<ul class="tags">
@@ -205,7 +205,7 @@ class CaseVersionResource(MTResource):
class Meta(MTResource.Meta):
queryset = CaseVersion.objects.all()
- fields = ["id", "name", "description", "case", "latest", "status"]
+ fields = ["id", "name", "description", "case", "status"]
filtering = {
"environments": ALL,
"productversion": ALL_WITH_RELATIONS,
@@ -353,13 +353,8 @@ class Meta:
def dehydrate(self, bundle):
"""Add some convenience fields to the return JSON."""
- case = bundle.obj
- cv = bundle.obj.versions.all()[0]
- bundle.data["case_id"] = unicode(case.id)
- bundle.data["name"] = unicode(cv.name)
- bundle.data["product_id"] = unicode(case.product_id)
- bundle.data["product"] = {"id": unicode(case.product_id)}
- bundle.data["order"] = case.order
+ bundle.data["name"] = unicode(bundle.obj.versions.all()[0].name)
+ bundle.data["order"] = bundle.obj.order
return bundle
View
@@ -187,8 +187,7 @@ var MT = (function (MT, $) {
ajax_trigger_filter: "product",
ajax_for_field: "suites",
for_type: "suite",
- ich_template: ich.case_select_item,
- use_latest: false
+ ich_template: ich.case_select_item
});
MT.populateMultiselectItems({
container: '#tag-add-form, #tag-edit-form',
@@ -112,34 +112,54 @@ def resource_name(self):
@property
def included_param(self):
- return "case__suites"
+ return "suites"
@property
def available_param(self):
return "{0}__ne".format(self.included_param)
- def get_exp_obj(self, cv, order=None):
+ def get_exp_obj(self, cv, order=None, suites=None):
"""Return an expected caseselection object with fields filled."""
+ if not suites:
+ suites = []
+ case = cv.case
+ product = case.product
+ pv = cv.productversion
+
return {
- u"case": unicode(
- self.get_detail_url("case", cv.case.id)),
- u"case_id": unicode(cv.case.id),
- u"created_by": None,
- u"id": unicode(cv.id),
- u"latest": True,
+ u'suites': [unicode(self.get_detail_url("suite", s.id)) for s in suites],
+ u"product": unicode(self.get_detail_url("product", product.id)),
u"name": unicode(cv.name),
+ u'versions': [{
+ u"case": unicode(
+ self.get_detail_url("case", case.id)),
+ u'product': {u'id': unicode(product.id)},
+ u"name": unicode(cv.name),
+ u'tags': [],
+ u'productversion_name': unicode(pv.name),
+ u'created_by': None,
+ u'case_id': unicode(cv.case.id),
+ u'productversion': {
+ u'product': unicode(self.get_detail_url(
+ "product", product.id)),
+ u'codename': u'',
+ u'version': unicode(pv.version),
+ u'id': unicode(pv.id),
+ u'resource_uri': unicode(self.get_detail_url(
+ "productversion", pv.id))
+ },
+ u'resource_uri': unicode(
+ self.get_detail_url("caseversionselection", cv.id)),
+ u'product_id': unicode(product.id),
+ u'id': unicode(cv.id),
+ u'latest': True
+ }],
+ u'id': unicode(case.id),
u"order": order,
- u"product": {
- u"id": unicode(cv.productversion.product_id)
- },
- u"product_id": unicode(cv.productversion.product_id),
- u"productversion": unicode(
- self.get_detail_url("productversion", cv.productversion.id)),
u"resource_uri": unicode(
- self.get_detail_url("caseselection", cv.id)),
- u"tags": [],
+ self.get_detail_url("caseselection", case.id)),
}
@@ -163,7 +183,7 @@ def _do_test(self, for_id, filter_param, exp_objects):
act = res.json
self.maxDiff = None
- self.assertEquals(act["meta"], self.get_exp_meta(len(exp_objects)))
+ self.assertEquals(self.get_exp_meta(len(exp_objects)), act["meta"])
self.assertEqual(exp_objects, act["objects"])
@@ -214,10 +234,16 @@ def test_included_for_two_included(self):
data = self._setup_two_included()
- exp_objects = [self.get_exp_obj(cv, order=sc.order) for cv, sc in [
- (data["cv1"], data["sc1"]),
- (data["cv2"], data["sc2"]),
- ]]
+ exp_objects = [
+ self.get_exp_obj(
+ cv,
+ order=sc.order,
+ suites=[data["s"]],
+ ) for cv, sc in [
+ (data["cv1"], data["sc1"]),
+ (data["cv2"], data["sc2"]),
+ ]
+ ]
self._do_test(
data["s"].id,
@@ -260,9 +286,13 @@ def test_included_for_one_included_one_not(self):
"""Get a list of included cases, one included"""
data = self._setup_for_one_included_one_not()
- exp_objects = [self.get_exp_obj(cv, order=sc.order) for cv, sc in [
- (data["cv1"], data["sc1"]),
- ]]
+ exp_objects = [
+ self.get_exp_obj(
+ cv,
+ order=sc.order,
+ suites=[data["s"]],
+ ) for cv, sc in [(data["cv1"], data["sc1"])]
+ ]
self._do_test(
data["s"].id,
@@ -281,21 +281,25 @@ def test_available_included_in_other_runs(self):
s1 = self.factory.create(name="Suite1")
s2 = self.factory.create(name="Suite2")
run1 = self.F.RunFactory.create()
- self.F.RunSuiteFactory.create(
+ runsuite1 = self.F.RunSuiteFactory.create(
run=run1, suite=s1, order=0)
- self.F.RunSuiteFactory.create(
+ runsuite2 = self.F.RunSuiteFactory.create(
run=run1, suite=s2, order=1)
run2 = self.F.RunFactory.create()
- self.F.RunSuiteFactory.create(
+ runsuite3 = self.F.RunSuiteFactory.create(
run=run2, suite=s1, order=0)
- self.F.RunSuiteFactory.create(
+ runsuite4 = self.F.RunSuiteFactory.create(
run=run2, suite=s2, order=1)
self._do_test(
-1,
self.available_param,
- [self.get_exp_obj(s, runs=[
- unicode(self.get_detail_url("run", run1.id)),
- unicode(self.get_detail_url("run", run2.id)),
- ]) for s in [s1, s2]],
+ [self.get_exp_obj(
+ s,
+ runs=[
+ unicode(self.get_detail_url("run", run1.id)),
+ unicode(self.get_detail_url("run", run2.id)),
+ ],
+ order=rs.order
+ ) for s, rs in [(s1, runsuite3), (s2, runsuite4)]],
)

0 comments on commit cca9804

Please sign in to comment.