import unittest import os import inspect import tools.path_tool import basic.program import test.testtools import basic.constants as B import test.constants as T import model.project import model.entity HOME_PATH = test.constants.HOME_PATH PYTHON_CMD = "python" TEST_FUNCTIONS = ["test_10getEntityNames", "test_11getEntities", "test_12getEntity", "test_13writeEntity" #, "test_14insertEntity" ] TEST_FUNCTIONS = ["test_14insertEntity"] PROGRAM_NAME = "clean_workspace" class MyTestCase(unittest.TestCase): mymsg = "--------------------------------------------------------------" 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() project = model.project.Project(job) entityNames = [] entityNames = project.read_unique_names(job, "", "", "", {}) self.assertEqual(type(entityNames), list) #entityNames = project.select_unique_names(job, "", "", "", {}) #self.assertEqual(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() project = model.project.Project(job) entityNames = [] entityNames = project.get_entities(job, storage=model.entity.STORAGE_FILE) self.assertEqual(type(entityNames), list) #entityNames = project.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() project = model.project.Project(job) name = "TESTPROJ" actproject = project.read_entity(job, name=name) self.assertEqual(getattr(actproject, model.project.FIELD_NAME), name) self.assertRaises(Exception, project.read_entity, job, "xyzxyz") # #actproject = project.select_entity(job, name) #self.assertEqual(getattr(actproject, model.project.FIELD_USERNAME), name) #self.assertRaises(Exception, project.select_entity, job, ["xyzxyz"]) def test_13writeEntity(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() def test_14insertEntity(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() project = model.project.Project(job) name = "TESTPROJ" actproject = project.read_entity(job, name=name) actproject.insert_entity(job) def collectInnerList(inList): outList = [] for r in inList: outList += r return outList if __name__ == '__main__': unittest.main()