Skip to content

Commit

Permalink
Add logging
Browse files Browse the repository at this point in the history
  • Loading branch information
mkoura committed Nov 12, 2018
1 parent 18fb161 commit 2b8f029
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 6 deletions.
8 changes: 8 additions & 0 deletions dump2polarion/requirements_exporter.py
Expand Up @@ -27,6 +27,7 @@
from __future__ import absolute_import, unicode_literals

import datetime
import logging
from collections import OrderedDict

import six
Expand All @@ -35,6 +36,9 @@
from dump2polarion import transform, utils
from dump2polarion.exceptions import Dump2PolarionException, NothingToDoException

# pylint: disable=invalid-name
logger = logging.getLogger(__name__)


class RequirementExport(object):
"""Exports requirements data into XML representation."""
Expand Down Expand Up @@ -158,10 +162,14 @@ def _requirement_element(self, parent_element, req_data):

title = req_data.get("title")
if not title:
logger.warning("Skipping requirement, title is missing")
return
req_id = req_data.get("id")

if not self._check_lookup_prop(req_id):
logger.warning(
"Skipping requirement `%s`, data missing for selected lookup method", title
)
return

attrs, custom_fields = self._classify_data(req_data)
Expand Down
20 changes: 14 additions & 6 deletions dump2polarion/testcases_exporter.py
Expand Up @@ -39,6 +39,7 @@
from __future__ import absolute_import, unicode_literals

import datetime
import logging
import re
from collections import OrderedDict

Expand All @@ -48,6 +49,9 @@
from dump2polarion import transform, utils
from dump2polarion.exceptions import Dump2PolarionException, NothingToDoException

# pylint: disable=invalid-name
logger = logging.getLogger(__name__)


class TestcaseExport(object):
"""Exports testcases data into XML representation."""
Expand Down Expand Up @@ -273,20 +277,24 @@ def _is_whitelisted(self, nodeid):

def _testcase_element(self, parent_element, testcase_data):
"""Adds testcase XML element."""
if not self._is_whitelisted(testcase_data.get("nodeid")):
nodeid = testcase_data.get("nodeid")
if not self._is_whitelisted(nodeid):
logger.debug("Skipping blacklisted node: %s", nodeid)
return
testcase_data = self._fill_project_defaults(testcase_data)
self._fill_automation_repo(testcase_data)
testcase_data = self._transform_result(testcase_data)
if not testcase_data:
return

title = testcase_data.get("title")
testcase_id = testcase_data.get("id")
if not (title or testcase_id):
return
testcase_title = testcase_data.get("title")

if not self._check_lookup_prop(testcase_id, title):
if not self._check_lookup_prop(testcase_id, testcase_title):
logger.warning(
"Skipping testcase `%s`, data missing for selected lookup method",
testcase_id or testcase_title,
)
return

attrs, custom_fields = self._classify_data(testcase_data)
Expand All @@ -295,7 +303,7 @@ def _testcase_element(self, parent_element, testcase_data):
testcase = etree.SubElement(parent_element, "testcase", attrs)

title_el = etree.SubElement(testcase, "title")
title_el.text = title
title_el.text = testcase_title

description = testcase_data.get("description")
if description:
Expand Down
9 changes: 9 additions & 0 deletions dump2polarion/xunit_exporter.py
Expand Up @@ -21,6 +21,7 @@
from __future__ import absolute_import, unicode_literals

import datetime
import logging
from collections import namedtuple

import six
Expand All @@ -32,6 +33,9 @@

ImportedData = namedtuple("ImportedData", "results testrun")

# pylint: disable=invalid-name
logger = logging.getLogger(__name__)


class XunitExport(object):
"""Exports testcases results into Polarion XUnit."""
Expand Down Expand Up @@ -227,12 +231,17 @@ def _gen_testcase(self, parent_element, result, records):

verdict = self._get_verdict(result)
if not verdict:
logger.warning("Skipping testcase, verdict is missing or invalid")
return

testcase_id = result.get("id")
testcase_title = result.get("title")

if not self._check_lookup_prop(testcase_id, testcase_title):
logger.warning(
"Skipping testcase `%s`, data missing for selected lookup method",
testcase_id or testcase_title,
)
return

testcase = self._testcase_element(
Expand Down

0 comments on commit 2b8f029

Please sign in to comment.