예제 #1
0
파일: __init__.py 프로젝트: rootxnet/Kiwi
 def to_xmlrpc(cls, query=None):
     """
     Convert the query set for XMLRPC
     """
     if query is None:
         query = {}
     serializer = Serializer(queryset=cls.objects.filter(**query))
     return serializer.serialize_queryset()
예제 #2
0
def get_links(query):
    """
    .. function:: XML-RPC TestExecution.get_links(query)

        Get URL links for the specified TestExecution

        :param query: Field lookups for
                      :class:`tcms.core.contrib.linkreference.models.LinkReference`
        :type query: dict
        :return: Serialized list of :class:`tcms.core.contrib.linkreference.models.LinkReference`
                 objects
    """
    links = LinkReference.objects.filter(**query)
    serialier = Serializer(links)
    return serialier.serialize_queryset()
예제 #3
0
def forward_copy_data(apps, schema_editor):
    bug_model = apps.get_model('testcases', 'Bug')
    link_reference_model = apps.get_model('linkreference', 'LinkReference')
    link_reference_ids = []

    for bug in bug_model.objects.all():
        file_name = '/tmp/kiwitcms-testcases-migrations-\
0010-Bug-%d' % bug.pk  # nosec:B108:hardcoded_tmp_directory
        with open(file_name, 'w') as outfile:
            json.dump(Serializer(model=bug).serialize_model(), outfile)

        if not bug.case_run_id:
            continue

        link_reference = link_reference_model.objects.create(
            execution_id=bug.case_run_id,
            name="%s %s" % (bug.bug_system.name, bug.bug_id),
            url=bug.bug_system.url_reg_exp % bug.bug_id,
            is_defect=True,
        )
        link_reference_ids.append(link_reference.pk)

    link_reference_ids_file_name = '/tmp/kiwitcms-testcases-migrations-0010-\
new-LinkReference-IDs'                        # nosec:B108:hardcoded_tmp_directory
    with open(link_reference_ids_file_name, 'w') as link_reference_ids_file:
        json.dump(link_reference_ids, link_reference_ids_file)
예제 #4
0
def forward_copy_data(apps, schema_editor):
    bug_model = apps.get_model("testcases", "Bug")
    link_reference_model = apps.get_model("linkreference", "LinkReference")
    link_reference_ids = []

    for bug in bug_model.objects.all():
        bug_file_name = "kiwitcms-testcases-migrations-0010-Bug-%d" % bug.pk
        bug_file = settings.TEMP_DIR / bug_file_name
        with bug_file.open("w") as outfile:
            json.dump(Serializer(model=bug).serialize_model(), outfile)

        if not bug.case_run_id:
            continue

        link_reference = link_reference_model.objects.create(
            execution_id=bug.case_run_id,
            name="%s %s" % (bug.bug_system.name, bug.bug_id),
            url=bug.bug_system.url_reg_exp % bug.bug_id,
            is_defect=True,
        )
        link_reference_ids.append(link_reference.pk)

    link_reference_ids_file_name = (
        "kiwitcms-testcases-migrations-0010-new-LinkReference-IDs")
    link_reference_ids_file = settings.TEMP_DIR / link_reference_ids_file_name
    with link_reference_ids_file.open("w") as outfile:
        json.dump(link_reference_ids, outfile)
def forwards_store_data(apps, schema_editor):
    bug_system_model = apps.get_model('testcases', 'BugSystem')

    for bug_system in bug_system_model.objects.all():
        file_name = '/tmp/kiwitcms-testcases-migration\
-0011-BugSystem-%d' % bug_system.pk  # nosec:B108:hardcoded_tmp_directory

        with open(file_name, 'w') as outfile:
            json.dump(Serializer(model=bug_system).serialize_model(), outfile)
예제 #6
0
    def test_serializer(self):
        serializer = Serializer(model=self.testcase)

        result = serializer.serialize_model()

        self.assertEqual(self.testcase.category.pk, result['category_id'])
        self.assertEqual(str(self.testcase.category), result['category'])

        component_pks = []

        for component in self.testcase.component.all():  # pylint: disable=no-member
            component_pks.append(component.pk)

        component_pks.sort()
        result['component'].sort()
        self.assertEqual(component_pks, result['component'])

        self.assertEqual(self.testcase.arguments, result['arguments'])
예제 #7
0
def forwards_store_data(apps, schema_editor):
    bug_system_model = apps.get_model("testcases", "BugSystem")

    for bug_system in bug_system_model.objects.all():
        file_name = "kiwitcms-testcases-migration-0011-BugSystem-%d" % bug_system.pk
        bug_file = settings.TEMP_DIR / file_name

        with bug_file.open("w") as outfile:
            json.dump(Serializer(model=bug_system).serialize_model(), outfile)
예제 #8
0
def forward_copy_data(apps, schema_editor):
    test_case_model = apps.get_model('testcases', 'TestCase')
    test_case_text_model = apps.get_model('testcases', 'TestCaseText')
    historical_test_case_model = apps.get_model('testcases', 'HistoricalTestCase')

    for test_case in test_case_model.objects.all():
        latest_text = test_case_text_model.objects.filter(case=test_case.pk).order_by('-pk').first()
        if latest_text:
            file_name = '/tmp/kiwitcms-testcases-migrations-0006-\
TestCaseText-%d' % latest_text.pk  # nosec:B108:hardcoded_tmp_directory
            with open(file_name, 'w') as outfile:
                json.dump(Serializer(model=latest_text).serialize_model(), outfile)

            test_case.case_text = convert_test_case_text(latest_text)
            test_case.save()
            # b/c the above will not generate history
            history = historical_test_case_model.objects.filter(
                case_id=test_case.pk
                ).order_by('-history_id').first()
            history.case_text = test_case.case_text
            history.save()
예제 #9
0
def forward_copy_data(apps, schema_editor):
    test_case_model = apps.get_model("testcases", "TestCase")
    test_case_text_model = apps.get_model("testcases", "TestCaseText")
    historical_test_case_model = apps.get_model("testcases",
                                                "HistoricalTestCase")

    for test_case in test_case_model.objects.all():
        latest_text = (test_case_text_model.objects.filter(
            case=test_case.pk).order_by("-pk").first())
        if latest_text:
            file_name = ("kiwitcms-testcases-migrations-0006-TestCaseText-%d" %
                         latest_text.pk)
            test_case_file = settings.TEMP_DIR / file_name
            with test_case_file.open("w") as outfile:
                json.dump(
                    Serializer(model=latest_text).serialize_model(), outfile)

            test_case.case_text = convert_test_case_text(latest_text)
            test_case.save()
            # b/c the above will not generate history
            history = (historical_test_case_model.objects.filter(
                case_id=test_case.pk).order_by("-history_id").first())
            history.case_text = test_case.case_text
            history.save()
예제 #10
0
파일: user.py 프로젝트: lcmtwn/Kiwi
def _get_user_dict(user):
    user_dict = Serializer(model=user).serialize_model()
    if 'password' in user_dict:
        del user_dict['password']
    return user_dict
예제 #11
0
def _get_user_dict(user):
    user_dict = Serializer(model=user).serialize_model()
    if "password" in user_dict:
        del user_dict["password"]
    return user_dict
예제 #12
0
파일: __init__.py 프로젝트: rootxnet/Kiwi
 def serialize(self):
     """
     Convert the model for XMLPRC
     """
     serializer = Serializer(model=self)
     return serializer.serialize_model()