Merge "Add proper references to xml schemas"
[functest-xtesting.git] / xtesting / core / campaign.py
index 60af3f4..51a145c 100644 (file)
@@ -26,6 +26,7 @@ from six.moves import urllib
 
 from xtesting.core import testcase
 from xtesting.utils import env
+from xtesting.utils import constants
 
 __author__ = "Cedric Ollivier <cedric.ollivier@orange.com>"
 
@@ -71,9 +72,17 @@ class Campaign():
                 "{}?build_tag={}".format(url, env.get('BUILD_TAG')),
                 headers=testcase.TestCase.headers)
             req.raise_for_status()
-            Campaign.__logger.debug("data from DB: \n%s", req.json())
+            output = req.json()
+            Campaign.__logger.debug("data from DB: \n%s", output)
+            for i, _ in enumerate(output["results"]):
+                for j, _ in enumerate(
+                        output["results"][i]["details"]["links"]):
+                    output["results"][i]["details"]["links"][j] = re.sub(
+                        "^{}/*".format(os.environ["HTTP_DST_URL"]), '',
+                        output["results"][i]["details"]["links"][j])
+            Campaign.__logger.debug("data to archive: \n%s", output)
             with open("{}.json".format(env.get('BUILD_TAG')), "w") as dfile:
-                json.dump(req.json(), dfile)
+                json.dump(output, dfile)
         except Exception:  # pylint: disable=broad-except
             Campaign.__logger.exception(
                 "The results cannot be collected from DB")
@@ -208,9 +217,9 @@ def main():
         os.makedirs(testcase.TestCase.dir_results)
     if env.get('DEBUG').lower() == 'true':
         logging.config.fileConfig(pkg_resources.resource_filename(
-            'xtesting', 'ci/logging.debug.ini'))
+            'xtesting', constants.DEBUG_INI_PATH))
     else:
         logging.config.fileConfig(pkg_resources.resource_filename(
-            'xtesting', 'ci/logging.ini'))
+            'xtesting', constants.INI_PATH))
     logging.captureWarnings(True)
     Campaign.zip_campaign_files()