import unittest import os import inspect import shutil #import model.entity #import model.environment #import model.application #import model.component import model.testcase import model.testsuite import model.factory import tools.path_tool import tools.job_tool import basic.program from basic.componentHandling import ComponentManager import test.constants import basic.constants as B import test.constants as T import basic.componentHandling import tools.file_tool HOME_PATH = test.constants.HOME_PATH PYTHON_CMD = "python" TEST_FUNCTIONS = ["test_00init", "test_11selectApplication", "test_12selectComponent", "test_13selectEnvironment", "test_14selectVariant", "test_16selectTestcase", "test_30startActJob"] TEST_FUNCTIONS = ["test_14selectVariant"] PROGRAM_NAME = "clean_workspace" class MyTestCase(unittest.TestCase): mymsg = "--------------------------------------------------------------" def test_00init(self): global mymsg actfunction = str(inspect.currentframe().f_code.co_name) cnttest = 0 if actfunction not in TEST_FUNCTIONS: return # simple job instantiate - without parameter and only simple messaging job = basic.program.Job(PROGRAM_NAME) print(str(job.__dict__)) self.checkSimpleJob(job) sjob = basic.program.SimpleJob(PROGRAM_NAME) print(str(sjob.__dict__)) self.checkSimpleJob(sjob) def checkSimpleJob(self, job): self.assertIn("conf", job.__dict__) self.assertIn("jobid", job.__dict__) self.assertIn("program", job.__dict__) self.assertIn("start", job.__dict__) self.assertIn("configpath", job.conf) self.assertIn("paths", job.conf) def test_11selectApplication(self): global mymsg actfunction = str(inspect.currentframe().f_code.co_name) cnttest = 0 if actfunction not in TEST_FUNCTIONS: return # simple job instantiate - without parameter and only simple messaging job = basic.program.Job(PROGRAM_NAME) res = tools.job_tool.select_application(job, {}, "TESTPROJ") self.assertIsInstance(res, list) print(str(res)) def test_30startActJob(self): global mymsg actfunction = str(inspect.currentframe().f_code.co_name) cnttest = 0 if actfunction not in TEST_FUNCTIONS: return # simple job instantiate - without parameter and only simple messaging job = basic.program.Job(PROGRAM_NAME) path = tools.path_tool.getActualJsonPath(job) args = tools.file_tool.read_file_dict(job, path, job.m) tools.job_tool.start_child_process(job, args) def test_12selectComponent(self): global mymsg actfunction = str(inspect.currentframe().f_code.co_name) cnttest = 0 if actfunction not in TEST_FUNCTIONS: return # simple job instantiate - without parameter and only simple messaging job = basic.program.Job(PROGRAM_NAME) # res = tools.job_tool.select_components(job, {}, "TESTPROJ", "") res = model.factory.getComponent(job).read_unique_names(job, "TESTPROJ", "", "", {}) self.assertIsInstance(res, list) print(str(res)) def test_13selectEnvironment(self): global mymsg actfunction = str(inspect.currentframe().f_code.co_name) cnttest = 0 if actfunction not in TEST_FUNCTIONS: return # simple job instantiate - without parameter and only simple messaging job = basic.program.Job(PROGRAM_NAME) #res = tools.job_tool.select_components(job, {}, "TESTPROJ", "") res = model.factory.getEnvironment(job).read_unique_names(job, "TESTPROJ", "", "", {}) self.assertIsInstance(res, list) print(str(res)) def test_14selectVariant(self): global mymsg actfunction = str(inspect.currentframe().f_code.co_name) cnttest = 0 if actfunction not in TEST_FUNCTIONS: return # simple job instantiate - without parameter and only simple messaging job = basic.program.Job(PROGRAM_NAME) args = {'proc': 'Testfall ausfuehren', 'gran': 'Testfall', 'user': 'ulrich', 'project': 'TESTPROJ', 'step': '1', 'program': 'test_executer', 'application': 'TESTAPP', 'environment': 'ENV01', 'testcase': 'TC0002'} res = tools.job_tool.select_variant(job, "", "Testfall", args) print(str(res)) self.assertEqual(2, len(res)) self.assertEqual("xml-rest", res[0]) args = {'proc': 'Testfall ausfuehren', 'gran': 'Testfall', 'user': 'ulrich', 'project': 'TESTPROJ', 'step': '1', 'program': 'test_executer', 'application': 'TESTAPP', 'environment': 'ENV01', 'testcase': 'TC0001'} res = tools.job_tool.select_variant(job, "", "Testfall", args) print(str(res)) self.assertEqual(2, len(res)) self.assertEqual("xml-rest", res[0]) def test_14selectTestplan(self): global mymsg actfunction = str(inspect.currentframe().f_code.co_name) cnttest = 0 if actfunction not in TEST_FUNCTIONS: return # simple job instantiate - without parameter and only simple messaging job = basic.program.Job(PROGRAM_NAME) #res = tools.job_tool.select_components(job, {}, "TESTPROJ", "") res = model.factory.getTestplan(job).read_unique_names(job, "TESTPROJ", "", "", {}) self.assertIsInstance(res, list) print(str(res)) def test_15selectTestsuite(self): global mymsg actfunction = str(inspect.currentframe().f_code.co_name) cnttest = 0 if actfunction not in TEST_FUNCTIONS: return # simple job instantiate - without parameter and only simple messaging job = basic.program.Job(PROGRAM_NAME) # res = tools.job_tool.select_components(job, {}, "TESTPROJ", "") res = model.environment.Environment(job).read_unique_names(job, "TESTPROJ", "", "", {}) self.assertIsInstance(res, list) print(str(res)) def test_16selectTestcase(self): global mymsg actfunction = str(inspect.currentframe().f_code.co_name) cnttest = 0 if actfunction not in TEST_FUNCTIONS: return # simple job instantiate - without parameter and only simple messaging args = {} args[B.PAR_PROJ] = "TESTPROJ" job = basic.program.Job(PROGRAM_NAME, args=args) #setattr(job, "par", object) #setattr(job.par, B.PAR_PROJ, "TESTPROJ") import model.testcase #outList = model.testcase.select_testcases(job, ["TESTPROJ"], ["TESTAPP"]) outList = tools.job_tool.select_testcase() outList = model.factory.getTestcase(job, "TESTPROJ").read_unique_names(job, "TESTPROJ", "TESTAPP", "", {}) #self.assertIsInstance(res, list) print(str(outList)) if __name__ == '__main__': unittest.main()