Browse Source

ExportResults fixed to accept custom path

bernhardbuhl 4 years ago
parent
commit
a4d84ec8ab

BIN
DropsTestRunDefinition.xlsx


+ 10 - 4
baangt.py

@@ -9,7 +9,8 @@ def args_read(l_search_parameter):
     l_args = sys.argv[1:]
 
     try:
-        opts, args = getopt.getopt(l_args, "", ["run="
+        opts, args = getopt.getopt(l_args, "", ["run=",
+                                                "globals="
                                                 ])
     except getopt.GetoptError as err_det:
         print("Error in reading parameters:" + str(err_det))
@@ -32,15 +33,20 @@ Call: python baangt.py --parameters
 
  Suggested for standard use:
    python baangt.py --run="Franzi4711.xlsx": Will run a Testrun Franzi4711.xlsx
-   python baangt.py --run="runProd.json": Will execute a Testrun as specified in runProd.json
+   python baangt.py --run="runProducts.json": Will execute a Testrun as specified in runProducts.json and use default globals.json, if exists
+   python baangt.py --run="runProducts.json" --globals="production.json" will use settings in production.json
+   python baangt.py --run="runProducts.json" --globals="qa.json" will use settings in qa.json
    """)
 
+
 def callTestrun():
     if ".XLSX" in testRunFile.upper() or ".JSON" in testRunFile.upper():
-        CustTestRun(testRunName=utils.sanitizeFileName(testRunFile), globalSettingsFileNameAndPath = globalSettingsFileName)
+        CustTestRun(testRunName=utils.sanitizeFileName(testRunFile),
+                    globalSettingsFileNameAndPath=utils.sanitizeFileName(globalSettingsFileName))
     else:
         sys.exit(f"Unknown Filetype - should be XLSX or JSON: {testRunFile}")
 
+
 def getGlobalSettings():
     lGlobals = args_read("globals")
     if not lGlobals:
@@ -50,7 +56,7 @@ def getGlobalSettings():
 
 print_args()
 
-testRunFile : str = args_read("run")
+testRunFile=args_read("run")
 if testRunFile:
     print(f"Starting Testrun: {testRunFile}")
 else:

+ 5 - 4
baangt/base/ExportResults.py

@@ -8,9 +8,10 @@ logger = logging.getLogger("pyC")
 
 class ExportResults:
     def __init__(self, **kwargs):
-        self.testRunName = kwargs.get(GC.KWARGS_TESTRUNINSTANCE).testRunName
+        self.testRunInstance = kwargs.get(GC.KWARGS_TESTRUNINSTANCE)
+        self.testRunName = self.testRunInstance.testRunName
         self.filename = self.__getOutputFileName()
-        logger.info("Export-Sheet für Ergebnisse: " + self.filename)
+        logger.info("Export-Sheet for results: " + self.filename)
         self.workbook = xlsxwriter.Workbook(self.filename)
         self.worksheet = self.workbook.add_worksheet("Output")
         self.dataRecords = kwargs.get(GC.KWARGS_TESTRUNINSTANCE).dataRecords
@@ -20,7 +21,7 @@ class ExportResults:
         self.closeExcel()
 
     def __getOutputFileName(self):
-        l_file = "/Users/bernhardbuhl/git/KatalonVIG/1testoutput/" + \
+        l_file = self.testRunInstance.globalSettings[GC.DATABASE_EXPORTFILENAMEANDPATH] + \
                  "baangt_" + self.testRunName + "_" + \
                  utils.datetime_return() + \
                  ".xlsx"
@@ -43,7 +44,7 @@ class ExportResults:
 
     def __writeCell(self, line, cellNumber, testRecordDict, fieldName, strip=False):
         if fieldName in testRecordDict.keys() and testRecordDict[fieldName]:
-            if '/n' in testRecordDict[fieldName][0:5] or strip:
+            if '\n' in testRecordDict[fieldName][0:5] or strip:
                 testRecordDict[fieldName] = testRecordDict[fieldName].strip()
             if isinstance(testRecordDict[fieldName], dict) or isinstance(testRecordDict[fieldName], list):
                 self.worksheet.write(line, cellNumber, testRecordDict[fieldName].strip())

+ 1 - 0
baangt/base/GlobalConstants.py

@@ -35,6 +35,7 @@ DATABASE_FROM_LINE = "FromLine"
 DATABASE_TO_LINE = "ToLine"
 DATABASE_FILENAME = "TestDataFileName"
 DATABASE_SHEETNAME = "Sheetname"
+DATABASE_EXPORTFILENAMEANDPATH = "exportFilesBasePath"
 
 STRUCTURE_TESTCASESEQUENCE = "TESTSEQUENCE"
 STRUCTURE_TESTCASE = "TESTCASE"

BIN
dropsApiTest.xlsx


+ 2 - 5
globals.json

@@ -1,6 +1,3 @@
 {
-  "base_url": "portal-fqa",
-  "user": "502266",
-  "password": "R(r6ayhr7EP3",
-  "file_praemienauskunft": "/Users/bernhardbuhl/git/KatalonVIG/0testdateninput/Test_unterschrift_Beratungsprotokoll.pdf"
-}
+  "exportFilesBasePath": ""
+}

+ 0 - 18
manual_run_API_EarthSquad.py

@@ -1,18 +0,0 @@
-from baangtVIG.CustTestRun import TestRun
-from baangt.base import GlobalConstants as GC
-from baangt.TestSteps.DropsApp.Login_API import Login_API
-
-if __name__ == '__main__':
-    #l_testRun = TestRun("WSTV-Single")
-    l_testRun = TestRun("API-DROPS")
-    ApiInterface = l_testRun.getAPI()
-    (l_record, l_count) = l_testRun.getNextRecord()
-
-    while l_record:
-        kwargs = {GC.KWARGS_DATA: l_record,
-                  GC.KWARGS_API_SESSION: ApiInterface}
-        Login_API(**kwargs)
-        l_testRun.finishTestCase()
-        (l_record, l_count) = l_testRun.getNextRecord()
-
-    l_testRun.tearDown()