def test_HeadConfigurationContentTest(self, file2Test, length): fileName = self.__getFilePathRelative2ThisTest(file2Test) configurationHandler = ConfigurationHandler(fileName) listOfHeadObjects = configurationHandler.getListOfHeadConfigurationObjects() assert len(listOfHeadObjects) == length, 'wrong head length' for head in listOfHeadObjects: name = head.getName() bleMac = head.getBleMac() index = listOfHeadObjects.index(head) + 1 listOfServers = head.getJobList() assert type(listOfServers) is dict, 'job object is not a dict' assert len(listOfServers) == 1, 'wrong job length in head: ' + name assert name == 'jenkins_head_{0}'.format(index), 'wrong head name' assert bleMac == '00:11:22:33:FF:{0:02d}'.format(index), 'wrong head ble mac' for serverName, jobList in listOfServers.items(): assert len(jobList) == index, 'wrong job length in head: ' + name for jobValue in jobList: jobParts = jobValue.split('/') jobIndex = jobList.index(jobValue) + 1 assert jobParts[0] == 'job{0}'.format(jobIndex), 'wrong job prefix' assert jobParts[1] == 'jenkins_head_{0}'.format(index), 'wrong job head name' assert jobParts[2] == serverName, 'wrong job postfix'
def test_HeadConfigurationErrorHandling(self, file2Test, expectation): fileName = self.__getFilePathRelative2ThisTest(file2Test) with expectation: configurationHandler = ConfigurationHandler(fileName) listOfHeadObjects = configurationHandler.getListOfHeadConfigurationObjects( ) listOfHeadObjects
def __init__(self, configFilePath: str): self.__listOfHeads = [] configManager = ConfigurationHandler(configFilePath) listOfHeadConfigs = configManager.getListOfHeadConfigurationObjects() for headConfig in listOfHeadConfigs: self.__listOfHeads.append(HeadHandler(headConfig))
def test_HeadConfigurationGetServerTest(self, file2Test, length): fileName = self.__getFilePathRelative2ThisTest(file2Test) configurationHandler = ConfigurationHandler(fileName) listOfHeadObjects = configurationHandler.getListOfHeadConfigurationObjects() assert len(listOfHeadObjects) > 0, 'wrong head length' for head in listOfHeadObjects: listOfServers = head.getJobList() for server in listOfServers: serverConfig = head.getServerParameter(server) assert serverConfig assert type(serverConfig) is dict, 'server config is not a dict'
def test_HeadHandlerCheck(self, mock_GattServerConnector, mock_JenkinsJobManager, headConfigFile, jenkinsStatus): instance = mock_JenkinsJobManager.return_value instance.getJobStatus.return_value = jenkinsStatus configurationHandler = ConfigurationHandler( os.path.join(os.path.dirname(__file__), headConfigFile)) headConfigurationList = configurationHandler.getListOfHeadConfigurationObjects( ) headHandler = HeadHandler(headConfigurationList[0]) headHandler.check() assert mock_GattServerConnector.mock_calls == [ mock.call('00:11:22:33:FF:01'), mock.call().sendStatus(jenkinsStatus) ]
def test_ConfigurationHandlerErrorHandling(self, file2Test, expectation): fileName = self.__getFilePathRelative2ThisTest(file2Test) with expectation: configurationHandler = ConfigurationHandler(fileName) configurationHandler