Skip to content

Commit

Permalink
api: Remove TestCase.get_components() in favor of Component.filter()
Browse files Browse the repository at this point in the history
internally it is used in only 1 place while Component.filter is much
more common and better covered with tests.

To filter components for a particular TC use:
JSON-RPC call -> ('Component.filter', [{'cases': TC.id}], callback);
  • Loading branch information
atodorov committed Aug 23, 2020
1 parent 452a50d commit 304d20e
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 23 deletions.
22 changes: 0 additions & 22 deletions tcms/rpc/api/testcase.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
'remove_comment',

'add_component',
'get_components',
'remove_component',

'add_notification_cc',
Expand Down Expand Up @@ -62,27 +61,6 @@ def add_component(case_id, component):
return case.serialize()


@permissions_required('testcases.view_testcase')
@rpc_method(name='TestCase.get_components')
def get_components(case_id):
"""
.. function:: XML-RPC TestCase.get_components(case_id)
Get the list of components attached to this case.
:param case_id: PK if TestCase
:type case_id: int
:return: Serialized list of :class:`tcms.management.models.Component` objects
:rtype: list(dict)
:raises: TestCase.DoesNotExist if missing test case matching PK
"""
test_case = TestCase.objects.get(pk=case_id)

component_ids = test_case.component.values_list('id', flat=True)
query = {'id__in': component_ids}
return Component.to_xmlrpc(query)


@permissions_required('testcases.delete_testcasecomponent')
@rpc_method(name='TestCase.remove_component')
def remove_component(case_id, component_id):
Expand Down
2 changes: 1 addition & 1 deletion tcms/testcases/static/testcases/js/get.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ $(document).ready(function() {
// components table
var components_table = $('#components').DataTable({
ajax: function(data, callback, settings) {
dataTableJsonRPC('TestCase.get_components', [case_id], callback);
dataTableJsonRPC('Component.filter', [{'cases': case_id}], callback);
},
columns: [
{ data: "name" },
Expand Down

0 comments on commit 304d20e

Please sign in to comment.