def update(run_id, values): """ .. function:: XML-RPC TestRun.update(run_id, values) Update the selected TestRun :param run_id: PK of TestRun to modify :type run_id: int :param values: Field values for :class:`tcms.testruns.models.TestRun` :type values: dict :return: Serialized :class:`tcms.testruns.models.TestRun` object :raises: PermissionDenied if missing *testruns.change_testrun* permission :raises: ValueError if data validations fail """ if (values.get('product_version') and not values.get('product')): raise ValueError('Field "product" is required by product_version') form = XMLRPCUpdateRunForm(values) if values.get('product_version'): form.populate(product_id=values['product']) if form.is_valid(): return _get_updated_test_run(run_id, values, form).serialize() raise ValueError(form_errors_to_list(form))
def update(run_id, values): """ .. function:: XML-RPC TestRun.update(run_id, values) Update the selected TestRun :param run_id: PK of TestRun to modify :type run_id: int :param values: Field values for :class:`tcms.testruns.models.TestRun` :type values: dict :return: Serialized :class:`tcms.testruns.models.TestRun` object :raises: PermissionDenied if missing *testruns.change_testrun* permission :raises: ValueError if data validations fail """ if values.get('product_version') and not values.get('product'): raise ValueError('Field "product" is required by product_version') form = XMLRPCUpdateRunForm(values) if values.get('product_version'): form.populate(product_id=values['product']) if not form.is_valid(): raise ValueError(form_errors_to_list(form)) test_run = TestRun.objects.get(pk=run_id) if form.cleaned_data['plan']: test_run.plan = form.cleaned_data['plan'] if form.cleaned_data['build']: test_run.build = form.cleaned_data['build'] if form.cleaned_data['manager']: test_run.manager = form.cleaned_data['manager'] test_run.default_tester = None if form.cleaned_data['default_tester']: test_run.default_tester = form.cleaned_data['default_tester'] if form.cleaned_data['summary']: test_run.summary = form.cleaned_data['summary'] if form.cleaned_data['product_version']: test_run.product_version = form.cleaned_data['product_version'] if 'notes' in values: if values['notes'] in (None, ''): test_run.notes = values['notes'] if form.cleaned_data['notes']: test_run.notes = form.cleaned_data['notes'] if form.cleaned_data['stop_date']: test_run.stop_date = form.cleaned_data['stop_date'] test_run.save() return test_run.serialize()
def update(request, run_ids, values): """Updates the fields of the selected test run. :param run_ids: give one or more run IDs. It could be an integer, a string containing comma separated IDs, or a list of int each of them is a run ID. :type run_ids: int, str or list :param dict values: a mapping containing these data to update specified runs. * plan: (int) TestPlan.plan_id * product: (int) Product.id * build: (int) Build.id * manager: (int) Auth.User.id * default_tester: Intege Auth.User.id * summary: (str) * estimated_time: (TimeDelta) in format ``2h30m30s`` which is recommended or ``HH:MM:SS``. * product_version: (int) * plan_text_version: (int) * notes: (str) * status: (int) 0:RUNNING 1:FINISHED :return: list of mappings of the updated test runs. :rtype: list[dict] .. versionchanged:: 4.5 Argument ``errata_id`` is removed. Example:: # Update status to finished for run 1 and 2 TestRun.update([1, 2], {'status': 1}) """ from datetime import datetime from tcms.core import forms from tcms.testruns.forms import XMLRPCUpdateRunForm if (values.get('product_version') and not values.get('product')): raise ValueError('Field "product" is required by product_version') if values.get('estimated_time'): values['estimated_time'] = pre_process_estimated_time( values.get('estimated_time')) form = XMLRPCUpdateRunForm(values) if values.get('product_version'): form.populate(product_id=values['product']) if form.is_valid(): trs = TestRun.objects.filter(pk__in=pre_process_ids(value=run_ids)) _values = dict() if form.cleaned_data['plan']: _values['plan'] = form.cleaned_data['plan'] if form.cleaned_data['build']: _values['build'] = form.cleaned_data['build'] if form.cleaned_data['manager']: _values['manager'] = form.cleaned_data['manager'] if 'default_tester' in values: default_tester = form.cleaned_data['default_tester'] if values.get('default_tester') and default_tester: _values['default_tester'] = default_tester else: _values['default_tester'] = None if form.cleaned_data['summary']: _values['summary'] = form.cleaned_data['summary'] if values.get('estimated_time') is not None: _values['estimated_time'] = form.cleaned_data['estimated_time'] if form.cleaned_data['product_version']: _values['product_version'] = form.cleaned_data['product_version'] if 'notes' in values: if values['notes'] in (None, ''): _values['notes'] = values['notes'] if form.cleaned_data['notes']: _values['notes'] = form.cleaned_data['notes'] if form.cleaned_data['plan_text_version']: _values['plan_text_version'] = form.cleaned_data[ 'plan_text_version'] if isinstance(form.cleaned_data['status'], int): if form.cleaned_data['status']: _values['stop_date'] = datetime.now() else: _values['stop_date'] = None trs.update(**_values) else: raise ValueError(forms.errors_to_list(form)) query = {'pk__in': trs.values_list('pk', flat=True)} return TestRun.to_xmlrpc(query)
def update(request, run_ids, values): """ Description: Updates the fields of the selected test run. Params: $run_ids - Integer/Array/String: An integer or alias representing the ID in the database, an array of run_ids, or a string of comma separated run_ids. $values - Hash of keys matching TestRun fields and the new values to set each field to. See params of TestRun.create for description +-------------------+----------------+--------------------------------+ | Field | Type | Description | +-------------------+----------------+--------------------------------+ | plan | Integer | TestPlan.plan_id | | product | Integer | Product.id | | build | Integer | Build.id | | manager | Integer | Auth.User.id | | default_tester | Intege | Auth.User.id | | summary | String | | | estimated_time | TimeDelta | 2h30m30s(recommend) or HH:MM:SS| | product_version | Integer | | | plan_text_version | Integer | | | notes | String | | | status | Integer | 0:RUNNING 1:FINISHED | +-------------------+----------------+ -------------------------------+ Returns: Hash: The updated test run object. Example: # Update status to finished for run 1193 and 1194 >>> TestRun.update([1193, 1194], {'status': 1}) """ from datetime import datetime from tcms.core import forms from tcms.testruns.forms import XMLRPCUpdateRunForm if (values.get('product_version') and not values.get('product')): raise ValueError('Field "product" is required by product_version') if values.get('estimated_time'): values['estimated_time'] = pre_process_estimated_time( values.get('estimated_time')) form = XMLRPCUpdateRunForm(values) if values.get('product_version'): form.populate(product_id=values['product']) if form.is_valid(): trs = TestRun.objects.filter(pk__in=pre_process_ids(value=run_ids)) _values = dict() if form.cleaned_data['plan']: _values['plan'] = form.cleaned_data['plan'] if form.cleaned_data['build']: _values['build'] = form.cleaned_data['build'] if form.cleaned_data['manager']: _values['manager'] = form.cleaned_data['manager'] if 'default_tester' in values: if values.get('default_tester') and \ form.cleaned_data['default_tester']: _values['default_tester'] = form.cleaned_data['default_tester'] else: _values['default_tester'] = None if form.cleaned_data['summary']: _values['summary'] = form.cleaned_data['summary'] if values.get('estimated_time') is not None: _values['estimated_time'] = form.cleaned_data['estimated_time'] if form.cleaned_data['product_version']: _values['product_version'] = form.cleaned_data['product_version'] if 'notes' in values: if values['notes'] in (None, ''): _values['notes'] = values['notes'] if form.cleaned_data['notes']: _values['notes'] = form.cleaned_data['notes'] if form.cleaned_data['plan_text_version']: _values['plan_text_version'] = form.cleaned_data[ 'plan_text_version'] if isinstance(form.cleaned_data['status'], int): if form.cleaned_data['status']: _values['stop_date'] = datetime.now() else: _values['stop_date'] = None trs.update(**_values) else: raise ValueError(forms.errors_to_list(form)) query = {'pk__in': trs.values_list('pk', flat=True)} return TestRun.to_xmlrpc(query)
def update(request, run_ids, values): """ Description: Updates the fields of the selected test run. Params: $run_ids - Integer/Array/String: An integer or alias representing the ID in the database, an array of run_ids, or a string of comma separated run_ids. $values - Hash of keys matching TestRun fields and the new values to set each field to. See params of TestRun.create for description +-------------------+----------------+--------------------------------+ | Field | Type | Description | +-------------------+----------------+--------------------------------+ | plan | Integer | TestPlan.plan_id | | product | Integer | Product.id | | build | Integer | Build.id | | errata_id | Integer | Errata.id | | manager | Integer | Auth.User.id | | default_tester | Intege | Auth.User.id | | summary | String | | | estimated_time | TimeDelta | 2h30m30s(recommend) or HH:MM:SS| | product_version | Integer | | | plan_text_version | Integer | | | notes | String | | | status | Integer | 0:RUNNING 1:FINISHED | +-------------------+----------------+ -------------------------------+ Returns: Hash: The updated test run object. Example: # Update status to finished for run 1193 and 1194 >>> TestRun.update([1193, 1194], {'status': 1}) """ from datetime import datetime from tcms.core import forms from tcms.testruns.forms import XMLRPCUpdateRunForm if (values.get('product_version') and not values.get('product')): raise ValueError('Field "product" is required by product_version') if values.get('estimated_time'): values['estimated_time'] = pre_process_estimated_time( values.get('estimated_time')) form = XMLRPCUpdateRunForm(values) if values.get('product_version'): form.populate(product_id=values['product']) if form.is_valid(): trs = TestRun.objects.filter(pk__in=pre_process_ids(value=run_ids)) _values = dict() if form.cleaned_data['plan']: _values['plan'] = form.cleaned_data['plan'] if form.cleaned_data['build']: _values['build'] = form.cleaned_data['build'] if form.cleaned_data['errata_id']: _values['errata_id'] = form.cleaned_data['errata_id'] if form.cleaned_data['manager']: _values['manager'] = form.cleaned_data['manager'] if 'default_tester' in values: if values.get('default_tester') and \ form.cleaned_data['default_tester']: _values['default_tester'] = form.cleaned_data['default_tester'] else: _values['default_tester'] = None if form.cleaned_data['summary']: _values['summary'] = form.cleaned_data['summary'] if values.get('estimated_time') is not None: _values['estimated_time'] = form.cleaned_data['estimated_time'] if form.cleaned_data['product_version']: _values['product_version'] = form.cleaned_data['product_version'] if 'notes' in values: if values['notes'] in (None, ''): _values['notes'] = values['notes'] if form.cleaned_data['notes']: _values['notes'] = form.cleaned_data['notes'] if form.cleaned_data['plan_text_version']: _values['plan_text_version'] = form.cleaned_data[ 'plan_text_version'] if isinstance(form.cleaned_data['status'], int): if form.cleaned_data['status']: _values['stop_date'] = datetime.now() else: _values['stop_date'] = None trs.update(**_values) else: raise ValueError(forms.errors_to_list(form)) query = {'pk__in': trs.values_list('pk', flat=True)} return TestRun.to_xmlrpc(query)
def update(request, run_ids, values): """Updates the fields of the selected test run. :param run_ids: give one or more run IDs. It could be an integer, a string containing comma separated IDs, or a list of int each of them is a run ID. :type run_ids: int, str or list :param dict values: a mapping containing these data to update specified runs. * plan: (int) TestPlan.plan_id * product: (int) Product.id * build: (int) Build.id * errata_id: (int) Errata.id * manager: (int) Auth.User.id * default_tester: Intege Auth.User.id * summary: (str) * estimated_time: (TimeDelta) in format ``2h30m30s`` which is recommended or ``HH:MM:SS``. * product_version: (int) * plan_text_version: (int) * notes: (str) * status: (int) 0:RUNNING 1:FINISHED :return: list of mappings of the updated test runs. :rtype: list[dict] Example:: # Update status to finished for run 1 and 2 >>> TestRun.update([1, 2], {'status': 1}) """ from datetime import datetime from tcms.core import forms from tcms.testruns.forms import XMLRPCUpdateRunForm if (values.get('product_version') and not values.get('product')): raise ValueError('Field "product" is required by product_version') if values.get('estimated_time'): values['estimated_time'] = pre_process_estimated_time( values.get('estimated_time')) form = XMLRPCUpdateRunForm(values) if values.get('product_version'): form.populate(product_id=values['product']) if form.is_valid(): trs = TestRun.objects.filter(pk__in=pre_process_ids(value=run_ids)) _values = dict() if form.cleaned_data['plan']: _values['plan'] = form.cleaned_data['plan'] if form.cleaned_data['build']: _values['build'] = form.cleaned_data['build'] if form.cleaned_data['errata_id']: _values['errata_id'] = form.cleaned_data['errata_id'] if form.cleaned_data['manager']: _values['manager'] = form.cleaned_data['manager'] if 'default_tester' in values: if values.get('default_tester') and \ form.cleaned_data['default_tester']: _values['default_tester'] = form.cleaned_data['default_tester'] else: _values['default_tester'] = None if form.cleaned_data['summary']: _values['summary'] = form.cleaned_data['summary'] if values.get('estimated_time') is not None: _values['estimated_time'] = form.cleaned_data['estimated_time'] if form.cleaned_data['product_version']: _values['product_version'] = form.cleaned_data['product_version'] if 'notes' in values: if values['notes'] in (None, ''): _values['notes'] = values['notes'] if form.cleaned_data['notes']: _values['notes'] = form.cleaned_data['notes'] if form.cleaned_data['plan_text_version']: _values['plan_text_version'] = form.cleaned_data[ 'plan_text_version'] if isinstance(form.cleaned_data['status'], int): if form.cleaned_data['status']: _values['stop_date'] = datetime.now() else: _values['stop_date'] = None trs.update(**_values) else: raise ValueError(forms.errors_to_list(form)) query = {'pk__in': trs.values_list('pk', flat=True)} return TestRun.to_xmlrpc(query)
def update(run_id, values): """ .. function:: XML-RPC TestRun.update(run_id, values) Update the selected TestRun :param run_id: PK of TestRun to modify :type run_id: int :param values: Field values for :class:`tcms.testruns.models.TestRun` :type values: dict :return: Serialized :class:`tcms.testruns.models.TestRun` object :raises: PermissionDenied if missing *testruns.change_testrun* permission :raises: ValueError if data validations fail """ if (values.get('product_version') and not values.get('product')): raise ValueError('Field "product" is required by product_version') if values.get('estimated_time'): values['estimated_time'] = pre_process_estimated_time( values.get('estimated_time')) form = XMLRPCUpdateRunForm(values) if values.get('product_version'): form.populate(product_id=values['product']) if form.is_valid(): tr = TestRun.objects.get(pk=run_id) if form.cleaned_data['plan']: tr.plan = form.cleaned_data['plan'] if form.cleaned_data['build']: tr.build = form.cleaned_data['build'] if form.cleaned_data['manager']: tr.manager = form.cleaned_data['manager'] if 'default_tester' in values: if values.get('default_tester') and \ form.cleaned_data['default_tester']: tr.default_tester = form.cleaned_data['default_tester'] else: tr.default_tester = None if form.cleaned_data['summary']: tr.summary = form.cleaned_data['summary'] if values.get('estimated_time') is not None: tr.estimated_time = form.cleaned_data['estimated_time'] if form.cleaned_data['product_version']: tr.product_version = form.cleaned_data['product_version'] if 'notes' in values: if values['notes'] in (None, ''): tr.notes = values['notes'] if form.cleaned_data['notes']: tr.notes = form.cleaned_data['notes'] if form.cleaned_data['plan_text_version']: tr.plan_text_version = form.cleaned_data['plan_text_version'] if isinstance(form.cleaned_data['status'], int): if form.cleaned_data['status']: tr.stop_date = datetime.now() else: tr.stop_date = None tr.save() else: raise ValueError(form_errors_to_list(form)) return tr.serialize()