def test_submit_new_run_with_results(self):

        envs = self.F.EnvironmentFactory.create_full_set(
                {"OS": ["OS X", "Linux"]})
        pv = self.F.ProductVersionFactory.create(environments=envs)
        c_p = self.F.CaseVersionFactory.create(
            case__product=pv.product,
            productversion=pv,
            )
        c_i = self.F.CaseVersionFactory.create(
            case__product=pv.product,
            productversion=pv,
            )
        c_f = self.F.CaseVersionFactory.create(
            case__product=pv.product,
            productversion=pv,
            )
        c_b = self.F.CaseVersionFactory.create(
            case__product=pv.product,
            productversion=pv,
            )
        c_s = self.F.CaseVersionFactory.create(
            case__product=pv.product,
            productversion=pv,
            )
        self.F.CaseStepFactory(caseversion=c_f)

        # submit results for these cases
        payload = {
            "description": "a description",
            "environments": [
                self.get_detail_url("environment", envs[0].id),
                ],
            "name": "atari autorun.sys",
            "productversion": self.get_detail_url("productversion", pv.id),
            "runcaseversions": [
                    {"case": c_i.case.id,
                     "comment": "what the hellfire?",
                     "environment": unicode(envs[0].id),
                     "status": "invalidated",
                     },
                    {"case": c_b.case.id,
                     "comment": "no can do",
                     "environment": envs[0].id,
                     "status": "blocked",
                     },
                    {"case": c_p.case.id,
                     "environment": envs[0].id,
                     "status": "passed"
                    },
                    {"case": c_s.case.id,
                     "environment": envs[0].id,
                     "status": "skipped"
                    },
                    {"bug": "http://www.deathvalleydogs.com",
                     "case": c_f.case.id,
                     "comment": "dang thing...",
                     "environment": envs[0].id,
                     "status": "failed",
                     "stepnumber": 1
                },
            ],
            "status": "active"
        }

        res = self.post(
            self.get_list_url(self.resource_name),
            payload=payload,
            params=self.auth_params,
            )

        # verify run
        run = self.model.Run.objects.get()
        self.assertEqual("atari autorun.sys", run.name)

        # verify returned content
        self.assertEqual(
            res.json["ui_uri"],
            u"/results/cases/?filter-run={0}".format(run.id),
            )

        # verify runcaseversions
        for cv in [c_f, c_p, c_i]:
            rcv = self.model.RunCaseVersion.objects.get(caseversion__id=cv.id)
            self.assertEqual(rcv.run.id, run.id)

        # verify pass results
        result = self.model.Result.objects.get(runcaseversion__caseversion=c_p)
        self.assertEqual(result.status, "passed")
        self.assertEqual(result.environment, envs[0])

        # verify fail results
        result = self.model.Result.objects.get(runcaseversion__caseversion=c_f)
        self.assertEqual(result.status, "failed")
        self.assertEqual(result.comment, "dang thing...")

        self.assertEqual(set(result.bug_urls()), set(["http://www.deathvalleydogs.com"]))
        self.assertEqual(result.environment, envs[0])

        # verify invalid results
        result = self.model.Result.objects.get(runcaseversion__caseversion=c_i)
        self.assertEqual(result.status, "invalidated")
        self.assertEqual(result.environment, envs[0])
        self.assertEqual(result.comment, "what the hellfire?")
Submit a new test run with results.
dataset/ETHPy150Open mozilla/moztrap/tests/model/execution/api/test_run.py/RunResourceTest.test_submit_new_run_with_results