tcms.xmlrpc.serializer module

class tcms.xmlrpc.serializer.BuildXMLRPCSerializer(model_class, queryset)[source]

Bases: tcms.xmlrpc.serializer.QuerySetBasedXMLRPCSerializer

Serializer for Build

values_fields_mapping = {'build_id': ('build_id', <function do_nothing at 0x7fcb2f1252f0>), 'description': ('description', <function do_nothing at 0x7fcb2f1252f0>), 'is_active': ('is_active', <function do_nothing at 0x7fcb2f1252f0>), 'name': ('name', <function do_nothing at 0x7fcb2f1252f0>), 'product': ('product_id', <function do_nothing at 0x7fcb2f1252f0>), 'product__name': ('product', <function do_nothing at 0x7fcb2f1252f0>)}
class tcms.xmlrpc.serializer.ProductXMLRPCSerializer(model_class, queryset)[source]

Bases: tcms.xmlrpc.serializer.QuerySetBasedXMLRPCSerializer

Serializer for Product

values_fields_mapping = {'classification': ('classification_id', <function do_nothing at 0x7fcb2f1252f0>), 'classification__name': ('classification', <function do_nothing at 0x7fcb2f1252f0>), 'description': ('description', <function do_nothing at 0x7fcb2f1252f0>), 'id': ('id', <function do_nothing at 0x7fcb2f1252f0>), 'name': ('name', <function do_nothing at 0x7fcb2f1252f0>)}
class tcms.xmlrpc.serializer.QuerySetBasedXMLRPCSerializer(model_class, queryset)[source]

Bases: tcms.xmlrpc.serializer.XMLRPCSerializer

XMLRPC serializer specific for TestPlan

To configure the serialization, developer can specify following class attribute, values_fields_mapping, m2m_fields, and primary_key.

An unknown issue is that the primary key must appear in the values_fields_mapping. If doesn’t, error would happen.

extra_fields = {}
get_extra_fields()[source]

Get definition of extra fields mappings

By default, user defined extra fields will be used. If not exist, an empty extra fields mapping is returned as to do nothing.

This method can also be override in subclass to provide the extra fields programatically.

serialize_queryset()[source]

Core of QuerySet based serialization

The process of serialization has following steps

  • Get data from database using QuerySet.values method

  • Transfer data to the output destiation according to serialization standard, where two things must be done, - field name must be replaced with right name rather than the

    internal name used for SQL query

    • some data must be converted in proper type. Currently, data with type datetime.datetime and datetime.timedelta must be converted to str (not UNICODE).
  • During the process of the above transfer, data associated with ManyToManyField should be retrieved from database and attached to each serialized data object.

values_fields_mapping = {}
class tcms.xmlrpc.serializer.TestCaseRunXMLRPCSerializer(model_class, queryset)[source]

Bases: tcms.xmlrpc.serializer.QuerySetBasedXMLRPCSerializer

XMLRPC serializer specific for TestCaseRun

values_fields_mapping = {'assignee': ('assignee_id', <function do_nothing at 0x7fcb2f1252f0>), 'assignee__username': ('assignee', <function to_str at 0x7fcb2f125620>), 'build': ('build_id', <function do_nothing at 0x7fcb2f1252f0>), 'build__name': ('build', <function do_nothing at 0x7fcb2f1252f0>), 'case': ('case_id', <function do_nothing at 0x7fcb2f1252f0>), 'case__summary': ('case', <function do_nothing at 0x7fcb2f1252f0>), 'case_run_id': ('case_run_id', <function do_nothing at 0x7fcb2f1252f0>), 'case_run_status': ('case_run_status_id', <function do_nothing at 0x7fcb2f1252f0>), 'case_run_status__name': ('case_run_status', <function do_nothing at 0x7fcb2f1252f0>), 'case_text_version': ('case_text_version', <function do_nothing at 0x7fcb2f1252f0>), 'close_date': ('close_date', <function datetime_to_str at 0x7fcb2f1256a8>), 'notes': ('notes', <function do_nothing at 0x7fcb2f1252f0>), 'run': ('run_id', <function do_nothing at 0x7fcb2f1252f0>), 'run__summary': ('run', <function do_nothing at 0x7fcb2f1252f0>), 'running_date': ('running_date', <function datetime_to_str at 0x7fcb2f1256a8>), 'sortkey': ('sortkey', <function do_nothing at 0x7fcb2f1252f0>), 'tested_by': ('tested_by_id', <function do_nothing at 0x7fcb2f1252f0>), 'tested_by__username': ('tested_by', <function to_str at 0x7fcb2f125620>)}
class tcms.xmlrpc.serializer.TestCaseXMLRPCSerializer(model_class, queryset)[source]

Bases: tcms.xmlrpc.serializer.QuerySetBasedXMLRPCSerializer

Serializer for TestCase

values_fields_mapping = {'alias': ('alias', <function do_nothing at 0x7fcb2f1252f0>), 'arguments': ('arguments', <function do_nothing at 0x7fcb2f1252f0>), 'author': ('author_id', <function do_nothing at 0x7fcb2f1252f0>), 'author__username': ('author', <function to_str at 0x7fcb2f125620>), 'case_id': ('case_id', <function do_nothing at 0x7fcb2f1252f0>), 'case_status': ('case_status_id', <function do_nothing at 0x7fcb2f1252f0>), 'case_status__name': ('case_status', <function do_nothing at 0x7fcb2f1252f0>), 'category': ('category_id', <function do_nothing at 0x7fcb2f1252f0>), 'category__name': ('category', <function do_nothing at 0x7fcb2f1252f0>), 'create_date': ('create_date', <function datetime_to_str at 0x7fcb2f1256a8>), 'default_tester': ('default_tester_id', <function do_nothing at 0x7fcb2f1252f0>), 'default_tester__username': ('default_tester', <function to_str at 0x7fcb2f125620>), 'extra_link': ('extra_link', <function do_nothing at 0x7fcb2f1252f0>), 'is_automated': ('is_automated', <function do_nothing at 0x7fcb2f1252f0>), 'is_automated_proposed': ('is_automated_proposed', <function do_nothing at 0x7fcb2f1252f0>), 'notes': ('notes', <function do_nothing at 0x7fcb2f1252f0>), 'priority': ('priority_id', <function do_nothing at 0x7fcb2f1252f0>), 'priority__value': ('priority', <function do_nothing at 0x7fcb2f1252f0>), 'requirement': ('requirement', <function do_nothing at 0x7fcb2f1252f0>), 'reviewer': ('reviewer_id', <function do_nothing at 0x7fcb2f1252f0>), 'reviewer__username': ('reviewer', <function to_str at 0x7fcb2f125620>), 'script': ('script', <function do_nothing at 0x7fcb2f1252f0>), 'summary': ('summary', <function do_nothing at 0x7fcb2f1252f0>)}
class tcms.xmlrpc.serializer.TestPlanXMLRPCSerializer(model_class, queryset)[source]

Bases: tcms.xmlrpc.serializer.QuerySetBasedXMLRPCSerializer

XMLRPC serializer specific for TestPlan

extra_fields = {'alias': {'product_version': 'default_product_version'}}
m2m_fields = ('case', 'tag')
values_fields_mapping = {'author': ('author_id', <function do_nothing at 0x7fcb2f1252f0>), 'author__username': ('author', <function to_str at 0x7fcb2f125620>), 'create_date': ('create_date', <function datetime_to_str at 0x7fcb2f1256a8>), 'extra_link': ('extra_link', <function do_nothing at 0x7fcb2f1252f0>), 'is_active': ('is_active', <function do_nothing at 0x7fcb2f1252f0>), 'name': ('name', <function do_nothing at 0x7fcb2f1252f0>), 'parent': ('parent_id', <function do_nothing at 0x7fcb2f1252f0>), 'parent__name': ('parent', <function do_nothing at 0x7fcb2f1252f0>), 'plan_id': ('plan_id', <function do_nothing at 0x7fcb2f1252f0>), 'product': ('product_id', <function do_nothing at 0x7fcb2f1252f0>), 'product__name': ('product', <function do_nothing at 0x7fcb2f1252f0>), 'product_version': ('product_version_id', <function do_nothing at 0x7fcb2f1252f0>), 'product_version__value': ('product_version', <function do_nothing at 0x7fcb2f1252f0>), 'text': ('text', <function do_nothing at 0x7fcb2f1252f0>), 'type': ('type_id', <function do_nothing at 0x7fcb2f1252f0>), 'type__name': ('type', <function do_nothing at 0x7fcb2f1252f0>)}
class tcms.xmlrpc.serializer.TestRunXMLRPCSerializer(model_class, queryset)[source]

Bases: tcms.xmlrpc.serializer.QuerySetBasedXMLRPCSerializer

Serializer for TestRun

values_fields_mapping = {'build': ('build_id', <function do_nothing at 0x7fcb2f1252f0>), 'build__name': ('build', <function do_nothing at 0x7fcb2f1252f0>), 'default_tester': ('default_tester_id', <function do_nothing at 0x7fcb2f1252f0>), 'default_tester__username': ('default_tester', <function to_str at 0x7fcb2f125620>), 'manager': ('manager_id', <function do_nothing at 0x7fcb2f1252f0>), 'manager__username': ('manager', <function to_str at 0x7fcb2f125620>), 'notes': ('notes', <function do_nothing at 0x7fcb2f1252f0>), 'plan': ('plan_id', <function do_nothing at 0x7fcb2f1252f0>), 'plan__name': ('plan', <function do_nothing at 0x7fcb2f1252f0>), 'product_version': ('product_version_id', <function do_nothing at 0x7fcb2f1252f0>), 'product_version__value': ('product_version', <function do_nothing at 0x7fcb2f1252f0>), 'run_id': ('run_id', <function do_nothing at 0x7fcb2f1252f0>), 'start_date': ('start_date', <function datetime_to_str at 0x7fcb2f1256a8>), 'stop_date': ('stop_date', <function datetime_to_str at 0x7fcb2f1256a8>), 'summary': ('summary', <function do_nothing at 0x7fcb2f1252f0>)}
class tcms.xmlrpc.serializer.XMLRPCSerializer(queryset=None, model=None)[source]

Bases: object

Django XMLRPC Serializer The goal is to process the datetime and timedelta data structure that python xmlrpc.client can not handle.

How to use it: # Model m = Model.objects.get(pk = 1) s = XMLRPCSerializer(model = m) s.serialize()

Or # QuerySet q = Model.objects.all() s = XMLRPCSerializer(queryset = q) s.serialize()

serialize_model()[source]

Check the fields of models and convert the data

Returns: Dictionary

serialize_queryset()[source]

Check the fields of QuerySet and convert the data

Returns: List

tcms.xmlrpc.serializer.datetime_to_str(value)[source]
tcms.xmlrpc.serializer.do_nothing(value)[source]
tcms.xmlrpc.serializer.timedelta_to_str(value)[source]
tcms.xmlrpc.serializer.to_str(value)[source]