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 Jan 26, 2018
1 parent 1c64d3c commit d83c7f1
Show file tree
Hide file tree
Showing 12 changed files with 122 additions and 118 deletions.
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:
14 changes: 12 additions & 2 deletions docs/source/modules/tcms.xmlrpc.api.env.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,17 @@
tcms\.xmlrpc\.api\.env module
=============================
tcms\.xmlrpc\.api\.env package
==============================

.. automodule:: tcms.xmlrpc.api.env
:members:
:undoc-members:
:show-inheritance:

Submodules
----------

.. toctree::

tcms.xmlrpc.api.env.group
tcms.xmlrpc.api.env.property
tcms.xmlrpc.api.env.value

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:
8 changes: 7 additions & 1 deletion docs/source/modules/tcms.xmlrpc.api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,20 @@ tcms\.xmlrpc\.api package
:undoc-members:
:show-inheritance:

Subpackages
-----------

.. toctree::

tcms.xmlrpc.api.env

Submodules
----------

.. toctree::

tcms.xmlrpc.api.auth
tcms.xmlrpc.api.build
tcms.xmlrpc.api.env
tcms.xmlrpc.api.product
tcms.xmlrpc.api.tag
tcms.xmlrpc.api.testcase
Expand Down
4 changes: 3 additions & 1 deletion tcms/settings/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,9 @@
MODERNRPC_METHODS_MODULES = [
'tcms.xmlrpc.api.auth',
'tcms.xmlrpc.api.build',
'tcms.xmlrpc.api.env',
'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.

3 changes: 3 additions & 0 deletions tcms/xmlrpc/api/env/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
""" """
# Note: empty doc-string because otherwise Sphinx will not pick this up
# when rendering the documentation
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 d83c7f1

Please sign in to comment.