import unittest import os import inspect import shutil import tools.path_tool import basic.program import test.testtools import basic.constants as B import test.constants as T import tools.file_tool import model.testsuite HOME_PATH = test.constants.HOME_PATH PYTHON_CMD = "python" TEST_FUNCTIONS = ["test_10getEnvironments"] TEST_FUNCTIONS = ["test_10getEntityNames", "test_11getEntities", "test_12getEntity", "test_13writeEntity", "test_14insertEntity"] TEST_FUNCTIONS = ["test_10getEntityNames", "test_12getEntity"] PROGRAM_NAME = "clean_workspace" class MyTestCase(unittest.TestCase): mymsg = "--------------------------------------------------------------" def test_10getEnvironments(self): global mymsg global jobObject 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 = test.testtools.getJob() print(str(job.__dict__)) jobObject = job projList = ["TESTPROJ"] appList = [] envs = model.testsuite.select_testsuites(job, projList, appList) print(str(envs)) def test_10getEntityNames(self): global mymsg global jobObject actfunction = str(inspect.currentframe().f_code.co_name) cnttest = 0 if actfunction not in TEST_FUNCTIONS: return job = test.testtools.getJob() testsuite = model.testsuite.Testsuite(job, "TESTPROJ") entityNames = testsuite.read_unique_names(job, "", "", "", {}) self.assertEqual(type(entityNames), list) #entityNames = project.select_unique_names(job, "", "", "", {}) #self.assertEquals(type(entityNames), list) def test_11getEntities(self): global mymsg global jobObject actfunction = str(inspect.currentframe().f_code.co_name) cnttest = 0 if actfunction not in TEST_FUNCTIONS: return job = test.testtools.getJob() testsuite = model.testsuite.Testsuite(job, "TESTPROJ") entityNames = [] entityNames = testsuite.get_entities(job, storage=model.entity.STORAGE_FILE) self.assertEqual(type(entityNames), list) #entityNames = testsuite.get_entities(job, storage=model.entity.STORAGE_DB) #self.assertEqual(type(entityNames), list) def test_12getEntity(self): global mymsg global jobObject actfunction = str(inspect.currentframe().f_code.co_name) cnttest = 0 if actfunction not in TEST_FUNCTIONS: return job = test.testtools.getJob() testsuite = model.testsuite.Testsuite(job, "TESTPROJ") name = "TST001" acttestsuite = testsuite.read_entity(job, name) self.assertEqual(getattr(acttestsuite, model.testsuite.FIELD_NAME), name) self.assertRaises(Exception, testsuite.read_entity, job, "xyzxyz") # #actrelease = release.select_entity(job, name) #self.assertEqual(getattr(actrelease, model.release.FIELD_NAME), name) #self.assertRaises(Exception, release.select_entity, job, ["xyzxyz"]) if __name__ == '__main__': unittest.main()