def create(values): """ .. function:: RPC TestRun.create(values) Create new TestRun object and store it in the database. :param values: Field values for :class:`tcms.testruns.models.TestRun` :type values: dict :return: Serialized :class:`tcms.testruns.models.TestRun` object :rtype: dict :raises PermissionDenied: if missing *testruns.add_testrun* permission :raises ValueError: if data validations fail Example:: >>> values = {'build': 384, 'manager': 137, 'plan': 137, 'summary': 'Testing XML-RPC for TCMS', } >>> TestRun.create(values) """ form = NewRunForm(values) form.populate(values.get('plan')) if form.is_valid(): test_run = form.save() return test_run.serialize() raise ValueError(form_errors_to_list(form))
def create(values): """ .. function:: RPC TestRun.create(values) Create new TestRun object and store it in the database. :param values: Field values for :class:`tcms.testruns.models.TestRun` :type values: dict :return: Serialized :class:`tcms.testruns.models.TestRun` object :rtype: dict :raises PermissionDenied: if missing *testruns.add_testrun* permission :raises ValueError: if data validations fail Example:: >>> values = {'build': 384, 'manager': 137, 'plan': 137, 'summary': 'Testing XML-RPC for TCMS', } >>> TestRun.create(values) """ form = NewRunForm(values) form.populate(values.get("plan")) if form.is_valid(): test_run = form.save() result = model_to_dict(test_run, exclude=["cc", "tag"]) # b/c value is set in the DB directly and if None # model_to_dict() will not return it result["start_date"] = test_run.start_date return result raise ValueError(form_errors_to_list(form))
def post(self, request): form = NewRunForm(data=request.POST) form.populate(request.POST.get("plan")) if form.is_valid(): test_run = form.save() # copy all of the selected properties into the test run for prop in EnvironmentProperty.objects.filter( environment__in=form.cleaned_data["environment"]): test_run.property_set.create(name=prop.name, value=prop.value) loop = 1 for case in form.cleaned_data["case"]: try: tcp = TestCasePlan.objects.get( plan=form.cleaned_data["plan"], case=case) sortkey = tcp.sortkey except ObjectDoesNotExist: sortkey = loop * 10 test_run.create_execution( case=case, assignee=form.cleaned_data["default_tester"], sortkey=sortkey, matrix_type=form.cleaned_data["matrix_type"], ) loop += 1 return HttpResponseRedirect( reverse( "testruns-get", args=[ test_run.pk, ], )) test_cases = (TestCase.objects.filter( pk__in=request.POST.getlist("case")).select_related( "author", "case_status", "category", "priority").order_by("pk")) context_data = { "plan_id": request.POST.get("plan"), "test_cases": test_cases, "form": form, "disabled_cases": get_disabled_test_cases_count(test_cases), } return render(request, self.template_name, context_data)
def post(self, request): form = NewRunForm(data=request.POST) form.populate(request.POST.get("plan")) if form.is_valid(): test_run = form.save() loop = 1 for case in form.cleaned_data["case"]: try: tcp = TestCasePlan.objects.get( plan=form.cleaned_data["plan"], case=case) sortkey = tcp.sortkey except ObjectDoesNotExist: sortkey = loop * 10 test_run.create_execution( case=case, sortkey=sortkey, assignee=form.cleaned_data["default_tester"], ) loop += 1 return HttpResponseRedirect( reverse( "testruns-get", args=[ test_run.pk, ], )) test_cases = TestCase.objects.filter( pk__in=request.POST.getlist("case")) tcs_values = test_cases.select_related("author", "case_status", "category", "priority").order_by("pk") context_data = { "test_cases": tcs_values, "form": form, "disabled_cases": get_disabled_test_cases_count(test_cases), } return render(request, self.template_name, context_data)
def post(self, request): form = NewRunForm(data=request.POST) form.populate(request.POST.get('plan')) if form.is_valid(): test_run = form.save() loop = 1 for case in form.cleaned_data['case']: try: tcp = TestCasePlan.objects.get( plan=form.cleaned_data['plan'], case=case) sortkey = tcp.sortkey except ObjectDoesNotExist: sortkey = loop * 10 test_run.create_execution( case=case, sortkey=sortkey, assignee=form.cleaned_data['default_tester']) loop += 1 return HttpResponseRedirect( reverse('testruns-get', args=[ test_run.pk, ])) test_cases = TestCase.objects.filter( pk__in=request.POST.getlist('case')) tcs_values = test_cases.select_related('author', 'case_status', 'category', 'priority').order_by('pk') context_data = { 'test_cases': tcs_values, 'form': form, 'disabled_cases': get_disabled_test_cases_count(test_cases) } return render(request, self.template_name, context_data)