Skip to content

Commit

Permalink
[rpc] Rename Env RPC methods. Refs #153
Browse files Browse the repository at this point in the history
	Env.filter_groups -> Env.Group.filter
	Env.filter_properties -> Env.Property.filter
	Env.filter_values -> Env.Value.filter
  • Loading branch information
atodorov committed Feb 2, 2018
1 parent 85501ed commit 93095e5
Show file tree
Hide file tree
Showing 11 changed files with 107 additions and 123 deletions.
7 changes: 0 additions & 7 deletions docs/source/modules/tcms.xmlrpc.api.env.rst

This file was deleted.

7 changes: 7 additions & 0 deletions docs/source/modules/tcms.xmlrpc.api.env_group.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
tcms\.xmlrpc\.api\.env\_group module
====================================

.. automodule:: tcms.xmlrpc.api.env_group
:members:
:undoc-members:
:show-inheritance:
7 changes: 7 additions & 0 deletions docs/source/modules/tcms.xmlrpc.api.env_property.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
tcms\.xmlrpc\.api\.env\_property module
=======================================

.. automodule:: tcms.xmlrpc.api.env_property
:members:
:undoc-members:
:show-inheritance:
7 changes: 7 additions & 0 deletions docs/source/modules/tcms.xmlrpc.api.env_value.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
tcms\.xmlrpc\.api\.env\_value module
====================================

.. automodule:: tcms.xmlrpc.api.env_value
:members:
:undoc-members:
:show-inheritance:
6 changes: 5 additions & 1 deletion docs/source/modules/tcms.xmlrpc.api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,11 @@ Submodules

tcms.xmlrpc.api.auth
tcms.xmlrpc.api.build
tcms.xmlrpc.api.env
tcms.xmlrpc.api.category
tcms.xmlrpc.api.component
tcms.xmlrpc.api.env_group
tcms.xmlrpc.api.env_property
tcms.xmlrpc.api.env_value
tcms.xmlrpc.api.product
tcms.xmlrpc.api.tag
tcms.xmlrpc.api.testcase
Expand Down
6 changes: 5 additions & 1 deletion tcms/settings/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,11 @@
MODERNRPC_METHODS_MODULES = [
'tcms.xmlrpc.api.auth',
'tcms.xmlrpc.api.build',
'tcms.xmlrpc.api.env',
'tcms.xmlrpc.api.category',
'tcms.xmlrpc.api.component',
'tcms.xmlrpc.api.env_group',
'tcms.xmlrpc.api.env_property',
'tcms.xmlrpc.api.env_value',
'tcms.xmlrpc.api.product',
'tcms.xmlrpc.api.testcase',
'tcms.xmlrpc.api.testcaserun',
Expand Down
108 changes: 0 additions & 108 deletions tcms/xmlrpc/api/env.py

This file was deleted.

24 changes: 24 additions & 0 deletions tcms/xmlrpc/api/env_group.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# -*- coding: utf-8 -*-

from modernrpc.core import rpc_method

from tcms.management.models import TCMSEnvGroup
from tcms.xmlrpc.utils import parse_bool_value


@rpc_method(name='Env.Group.filter')
def filter(query):
"""
.. function:: XML-RPC Env.Group.filter(query)
Perform a search and return the resulting list of
:class:`tcms.management.models.TCMSEnvGroup` objects.
:param query: Field lookups for :class:`tcms.management.models.TCMSEnvGroup`
:type query: dict
:returns: List of serialized :class:`tcms.management.models.TCMSEnvGroup` objects
:rtype: list(dict)
"""
if 'is_active' in query:
query['is_active'] = parse_bool_value(query['is_active'])
return TCMSEnvGroup.to_xmlrpc(query)
23 changes: 23 additions & 0 deletions tcms/xmlrpc/api/env_property.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# -*- coding: utf-8 -*-

from modernrpc.core import rpc_method

from tcms.management.models import TCMSEnvProperty
from tcms.xmlrpc.utils import parse_bool_value


@rpc_method(name='Env.Property.filter')
def filter(query):
"""
.. function:: XML-RPC Env.Property.filter(query)
Performs a search and returns the resulting list of environment properties.
:param query: Field lookups for :class:`tcms.management.models.TCMSEnvProperty`
:type query: dict
:returns: List of serialized :class:`tcms.management.models.TCMSEnvProperty` objects
:rtype: list(dict)
"""
if 'is_active' in query:
query['is_active'] = parse_bool_value(query['is_active'])
return TCMSEnvProperty.to_xmlrpc(query)
23 changes: 23 additions & 0 deletions tcms/xmlrpc/api/env_value.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# -*- coding: utf-8 -*-

from modernrpc.core import rpc_method

from tcms.management.models import TCMSEnvValue
from tcms.xmlrpc.utils import parse_bool_value


@rpc_method(name='Env.Value.filter')
def filter(query):
"""
.. function:: XML-RPC Env.Value.filter(query)
Performs a search and returns the resulting list of environment values.
:param query: Field lookups for :class:`tcms.management.models.TCMSEnvValue`
:type query: dict
:returns: List of serialized :class:`tcms.management.models.TCMSEnvValue` objects
:rtype: list(dict)
"""
if 'is_active' in query:
query['is_active'] = parse_bool_value(query['is_active'])
return TCMSEnvValue.to_xmlrpc(query)
12 changes: 6 additions & 6 deletions tcms/xmlrpc/tests/test_logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,22 +20,22 @@ def assertArgsNotLogged(self, rpc_method):

@patch('tcms.xmlrpc.handlers.settings.DEBUG', new=False)
def test_logging_with_authenticated_user(self):
log_count = XmlRpcLog.objects.filter(user=self.api_user, method='Env.filter_groups').count()
log_count = XmlRpcLog.objects.filter(user=self.api_user, method='Env.Group.filter').count()

self.rpc_client.Env.filter_groups({})
new_count = XmlRpcLog.objects.filter(user=self.api_user, method='Env.filter_groups').count()
self.rpc_client.Env.Group.filter({})
new_count = XmlRpcLog.objects.filter(user=self.api_user, method='Env.Group.filter').count()

self.assertEqual(new_count, log_count + 1)

@patch('tcms.xmlrpc.handlers.settings.DEBUG', new=False)
def test_logging_with_anonymous_user(self):
log_count = XmlRpcLog.objects.filter(user__username='Anonymous',
method='Env.filter_groups').count()
method='Env.Group.filter').count()

self.rpc_client.Auth.logout()
self.rpc_client.Env.filter_groups({})
self.rpc_client.Env.Group.filter({})
new_count = XmlRpcLog.objects.filter(user__username='Anonymous',
method='Env.filter_groups').count()
method='Env.Group.filter').count()

self.assertEqual(new_count, log_count + 1)

Expand Down

0 comments on commit 93095e5

Please sign in to comment.