Skip to content

Commit

Permalink
Rename RPC related classes. Fixes kiwitcms#682
Browse files Browse the repository at this point in the history
  • Loading branch information
rsasov committed Jan 19, 2020
1 parent eed30cc commit 612f97a
Show file tree
Hide file tree
Showing 19 changed files with 86 additions and 86 deletions.
8 changes: 4 additions & 4 deletions tcms/management/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
from django.db import models

from tcms.core.models import TCMSActionModel
from tcms.rpc.serializer import ProductXMLRPCSerializer
from tcms.rpc.serializer import BuildXMLRPCSerializer
from tcms.rpc.serializer import BuildRPCSerializer
from tcms.rpc.serializer import ProductRPCSerializer


class Classification(TCMSActionModel):
Expand All @@ -32,7 +32,7 @@ def __str__(self):
def to_xmlrpc(cls, query=None):
_query = query or {}
query_set = cls.objects.filter(**_query).order_by('pk')
serializer = ProductXMLRPCSerializer(model_class=cls, queryset=query_set)
serializer = ProductRPCSerializer(model_class=cls, queryset=query_set)
return serializer.serialize_queryset()

def save(self, force_insert=False, force_update=False, using=None,
Expand Down Expand Up @@ -132,7 +132,7 @@ class Meta:
def to_xmlrpc(cls, query=None):
query = query or {}
query_set = cls.objects.filter(**query).order_by('pk')
serializer = BuildXMLRPCSerializer(model_class=cls, queryset=query_set)
serializer = BuildRPCSerializer(model_class=cls, queryset=query_set)
return serializer.serialize_queryset()

def __str__(self):
Expand Down
17 changes: 9 additions & 8 deletions tcms/rpc/serializer.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
SECONDS_PER_HOUR = 3600
SECONDS_PER_DAY = 86400


# ## Data format conversion functions ###


Expand All @@ -36,7 +37,7 @@ def timedelta_to_str(value):
hours = total_seconds / SECONDS_PER_HOUR
# minutes - Total seconds subtract the used hours
minutes = total_seconds / SECONDS_PER_MIN - \
total_seconds / SECONDS_PER_HOUR * 60
total_seconds / SECONDS_PER_HOUR * 60
seconds = total_seconds % SECONDS_PER_MIN
return '%02i:%02i:%02i' % (hours, minutes, seconds)

Expand Down Expand Up @@ -170,7 +171,7 @@ def _serialize_names(row, values_fields_mapping):
return new_serialized_data


class QuerySetBasedXMLRPCSerializer(Serializer):
class QuerySetBasedRPCSerializer(Serializer):
"""XMLRPC serializer specific for TestPlan
To configure the serialization, developer can specify following class
Expand Down Expand Up @@ -386,7 +387,7 @@ def serialize_queryset(self):
return serialize_result


class TestPlanXMLRPCSerializer(QuerySetBasedXMLRPCSerializer):
class TestPlanRPCSerializer(QuerySetBasedRPCSerializer):
"""XMLRPC serializer specific for TestPlan"""

values_fields_mapping = {
Expand Down Expand Up @@ -416,7 +417,7 @@ class TestPlanXMLRPCSerializer(QuerySetBasedXMLRPCSerializer):
m2m_fields = ('case', 'tag')


class TestExecutionXMLRPCSerializer(QuerySetBasedXMLRPCSerializer):
class TestExecutionRPCSerializer(QuerySetBasedRPCSerializer):
"""XMLRPC serializer specific for TestExecution"""

values_fields_mapping = {
Expand All @@ -440,7 +441,7 @@ class TestExecutionXMLRPCSerializer(QuerySetBasedXMLRPCSerializer):
}


class TestRunXMLRPCSerializer(QuerySetBasedXMLRPCSerializer):
class TestRunRPCSerializer(QuerySetBasedRPCSerializer):
"""Serializer for TestRun"""

values_fields_mapping = {
Expand All @@ -463,7 +464,7 @@ class TestRunXMLRPCSerializer(QuerySetBasedXMLRPCSerializer):
}


class TestCaseXMLRPCSerializer(QuerySetBasedXMLRPCSerializer):
class TestCaseRPCSerializer(QuerySetBasedRPCSerializer):
"""Serializer for TestCase"""

values_fields_mapping = {
Expand Down Expand Up @@ -493,7 +494,7 @@ class TestCaseXMLRPCSerializer(QuerySetBasedXMLRPCSerializer):
}


class ProductXMLRPCSerializer(QuerySetBasedXMLRPCSerializer):
class ProductRPCSerializer(QuerySetBasedRPCSerializer):
"""Serializer for Product"""

values_fields_mapping = {
Expand All @@ -505,7 +506,7 @@ class ProductXMLRPCSerializer(QuerySetBasedXMLRPCSerializer):
}


class BuildXMLRPCSerializer(QuerySetBasedXMLRPCSerializer):
class BuildRPCSerializer(QuerySetBasedRPCSerializer):
"""Serializer for Build"""

values_fields_mapping = {
Expand Down
4 changes: 2 additions & 2 deletions tcms/rpc/tests/test_category.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# -*- coding: utf-8 -*-
# pylint: disable=attribute-defined-outside-init, invalid-name, objects-update-used

from tcms.rpc.tests.utils import XmlrpcAPIBaseTest
from tcms.rpc.tests.utils import RpcAPIBaseTest
from tcms.tests.factories import CategoryFactory, ProductFactory


class TestCategory(XmlrpcAPIBaseTest):
class TestCategory(RpcAPIBaseTest):

def _fixture_setup(self):
super(TestCategory, self)._fixture_setup()
Expand Down
8 changes: 4 additions & 4 deletions tcms/rpc/tests/test_component.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
from xmlrpc.client import Fault as XmlRPCFault
from xmlrpc.client import ProtocolError

from tcms.rpc.tests.utils import XmlrpcAPIBaseTest
from tcms.rpc.tests.utils import RpcAPIBaseTest
from tcms.tests.factories import ComponentFactory, ProductFactory


class TestFilterComponents(XmlrpcAPIBaseTest):
class TestFilterComponents(RpcAPIBaseTest):
def _fixture_setup(self):
super(TestFilterComponents, self)._fixture_setup()

Expand All @@ -31,7 +31,7 @@ def test_filter_non_existing(self):
self.assertEqual(0, len(found))


class TestCreateComponent(XmlrpcAPIBaseTest):
class TestCreateComponent(RpcAPIBaseTest):

def _fixture_setup(self):
super(TestCreateComponent, self)._fixture_setup()
Expand All @@ -57,7 +57,7 @@ def test_add_component_with_no_perms(self):
self.rpc_client.exec.Component.create(self.product.pk, "MyComponent")


class TestUpdateComponent(XmlrpcAPIBaseTest):
class TestUpdateComponent(RpcAPIBaseTest):
# pylint: disable=objects-update-used
def _fixture_setup(self):
super(TestUpdateComponent, self)._fixture_setup()
Expand Down
4 changes: 2 additions & 2 deletions tcms/rpc/tests/test_plantype.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# -*- coding: utf-8 -*-
# pylint: disable=attribute-defined-outside-init

from tcms.rpc.tests.utils import XmlrpcAPIBaseTest
from tcms.rpc.tests.utils import RpcAPIBaseTest
from tcms.tests.factories import PlanTypeFactory


class PlanTypeMethods(XmlrpcAPIBaseTest):
class PlanTypeMethods(RpcAPIBaseTest):

def _fixture_setup(self):
super(PlanTypeMethods, self)._fixture_setup()
Expand Down
4 changes: 2 additions & 2 deletions tcms/rpc/tests/test_product.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# -*- coding: utf-8 -*-
# pylint: disable=attribute-defined-outside-init

from tcms.rpc.tests.utils import XmlrpcAPIBaseTest
from tcms.rpc.tests.utils import RpcAPIBaseTest
from tcms.tests.factories import ProductFactory


class TestFilter(XmlrpcAPIBaseTest):
class TestFilter(RpcAPIBaseTest):

def _fixture_setup(self):
super(TestFilter, self)._fixture_setup()
Expand Down
10 changes: 5 additions & 5 deletions tcms/rpc/tests/test_serializer.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from django.utils import timezone

from tcms.management.models import Product
from tcms.rpc.serializer import (QuerySetBasedXMLRPCSerializer, Serializer,
from tcms.rpc.serializer import (QuerySetBasedRPCSerializer, Serializer,
_get_related_object_pks, datetime_to_str,
do_nothing, to_str)
from tcms.testcases.models import TestCase
Expand Down Expand Up @@ -58,7 +58,7 @@ def test_datetime_to_str(self):
self.assertEqual(expected_value, value)


class MockTestPlanSerializer(QuerySetBasedXMLRPCSerializer):
class MockTestPlanSerializer(QuerySetBasedRPCSerializer):
values_fields_mapping = {
'create_date': ('create_date', datetime_to_str),
'extra_link': ('extra_link', do_nothing),
Expand All @@ -79,7 +79,7 @@ class MockTestPlanSerializer(QuerySetBasedXMLRPCSerializer):
m2m_fields = ('case',)


class MockTestCaseSerializer(QuerySetBasedXMLRPCSerializer):
class MockTestCaseSerializer(QuerySetBasedRPCSerializer):
primary_key = 'case_id'

values_fields_mapping = {
Expand All @@ -95,7 +95,7 @@ class MockTestCaseSerializer(QuerySetBasedXMLRPCSerializer):


class TestQuerySetBasedSerializer(test.TestCase):
"""Test QuerySetBasedXMLRPCSerializer"""
"""Test QuerySetBasedRPCSerializer"""

@classmethod
def setUpTestData(cls):
Expand Down Expand Up @@ -143,7 +143,7 @@ def setUpTestData(cls):
product_keys.append(product.pk)

cls.products = Product.objects.filter(pk__in=product_keys)
cls.product_serializer = QuerySetBasedXMLRPCSerializer(Product, cls.products)
cls.product_serializer = QuerySetBasedRPCSerializer(Product, cls.products)

def test_get_values_fields_mapping(self):
mapping = self.product_serializer._get_values_fields_mapping()
Expand Down
4 changes: 2 additions & 2 deletions tcms/rpc/tests/test_tag.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# -*- coding: utf-8 -*-
# pylint: disable=attribute-defined-outside-init

from tcms.rpc.tests.utils import XmlrpcAPIBaseTest
from tcms.rpc.tests.utils import RpcAPIBaseTest
from tcms.tests.factories import TagFactory


class Tag(XmlrpcAPIBaseTest):
class Tag(RpcAPIBaseTest):
def _fixture_setup(self):
super(Tag, self)._fixture_setup()

Expand Down
8 changes: 4 additions & 4 deletions tcms/rpc/tests/test_testbuild.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
from xmlrpc.client import Fault as XmlRPCFault
from xmlrpc.client import ProtocolError

from tcms.rpc.tests.utils import XmlrpcAPIBaseTest
from tcms.rpc.tests.utils import RpcAPIBaseTest
from tcms.tests.factories import BuildFactory, ProductFactory


class BuildCreate(XmlrpcAPIBaseTest):
class BuildCreate(RpcAPIBaseTest):

def _fixture_setup(self):
super(BuildCreate, self)._fixture_setup()
Expand Down Expand Up @@ -80,7 +80,7 @@ def test_build_create(self):
self.assertEqual(b['is_active'], False)


class BuildUpdate(XmlrpcAPIBaseTest):
class BuildUpdate(RpcAPIBaseTest):

def _fixture_setup(self):
super(BuildUpdate, self)._fixture_setup()
Expand Down Expand Up @@ -124,7 +124,7 @@ def test_build_update(self):
self.assertEqual(b['name'], 'Update')


class BuildFilter(XmlrpcAPIBaseTest):
class BuildFilter(RpcAPIBaseTest):

def _fixture_setup(self):
super(BuildFilter, self)._fixture_setup()
Expand Down
16 changes: 8 additions & 8 deletions tcms/rpc/tests/test_testcase.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@
from django.contrib.auth.models import Permission
from tcms_api import xmlrpc

from tcms.rpc.tests.utils import XmlrpcAPIBaseTest
from tcms.management.models import Priority
from tcms.rpc.tests.utils import RpcAPIBaseTest
from tcms.testcases.models import Category, TestCase, TestCaseStatus
from tcms.tests import remove_perm_from_user
from tcms.tests.factories import (CategoryFactory, ComponentFactory,
ProductFactory, TagFactory, TestCaseFactory,
TestPlanFactory, UserFactory, VersionFactory)


class TestNotificationRemoveCC(XmlrpcAPIBaseTest):
class TestNotificationRemoveCC(RpcAPIBaseTest):
""" Tests the XML-RPC testcase.notication_remove_cc method """

def _fixture_setup(self):
Expand All @@ -39,7 +39,7 @@ def test_remove_existing_cc(self):
self.assertEqual([], self.testcase.emailing.get_cc_list())


class TestFilterCases(XmlrpcAPIBaseTest):
class TestFilterCases(RpcAPIBaseTest):

def _fixture_setup(self):
super(TestFilterCases, self)._fixture_setup()
Expand Down Expand Up @@ -69,7 +69,7 @@ def test_filter_by_product_id(self):
self.assertEqual(len(cases), self.cases_count)


class TestUpdate(XmlrpcAPIBaseTest):
class TestUpdate(RpcAPIBaseTest):

def _fixture_setup(self):
super()._fixture_setup()
Expand Down Expand Up @@ -114,7 +114,7 @@ def test_update_author_issue_630(self):
self.assertEqual(self.new_author.pk, updated['author_id'])


class TestCreate(XmlrpcAPIBaseTest):
class TestCreate(RpcAPIBaseTest):
def _fixture_setup(self):
super()._fixture_setup()

Expand Down Expand Up @@ -165,7 +165,7 @@ def test_fails_when_mandatory_fields_not_specified(self):
)


class TestAddTag(XmlrpcAPIBaseTest):
class TestAddTag(RpcAPIBaseTest):

def _fixture_setup(self):
super()._fixture_setup()
Expand Down Expand Up @@ -200,7 +200,7 @@ def test_add_tag_without_permissions(self):
self.assertFalse(tag_exists)


class TestRemoveTag(XmlrpcAPIBaseTest):
class TestRemoveTag(RpcAPIBaseTest):

def _fixture_setup(self):
super()._fixture_setup()
Expand Down Expand Up @@ -239,7 +239,7 @@ def test_remove_tag_without_permissions(self):
self.assertFalse(tag_exists)


class TestAddComponent(XmlrpcAPIBaseTest):
class TestAddComponent(RpcAPIBaseTest):

def _fixture_setup(self):
super()._fixture_setup()
Expand Down
Loading

0 comments on commit 612f97a

Please sign in to comment.