def testShouldHaveUsernameandAtLeastOneHostnameSetUp(self): self.__setUpConfigFile() properties = Property(self.configfile) properties.parse_properties() logging.debug(properties.get_keys()) defaults = self.__getDefaults() defaults['properties'] = properties logtailer = SSHLogTailer(defaults) self.assertTrue(logtailer.sanityCheck())
def testIfParametersNotProvidedShouldExit(self): fh = open('wrongconfigfile','w') fh.write('anything = anything\n') fh.close() properties = Property('wrongconfigfile') properties.parse_properties() defaults = self.__getDefaults() defaults['properties'] = properties logtailer = SSHLogTailer(defaults) self.assertFalse(logtailer.sanityCheck())
def testItShouldhaveBuildADictWithAllParamsIfAllParametersOk(self): self.__setUpConfigFile() properties = Property(self.configfile) properties.parse_properties() logging.debug(properties.get_keys()) defaults = self.__getDefaults() defaults['properties'] = properties logtailer = SSHLogTailer(defaults) logtailer.sanityCheck() self.assertEquals(3,len(logtailer.hostnames.keys())) self.assertEquals('username',logtailer.hostnames['hostname0']['username'])
def testshouldBuildCommandTailBasedOnHostnamesDict(self): self.__setUpConfigFile() properties = Property(self.configfile) properties.parse_properties() logging.debug(properties.get_keys()) defaults = self.__getDefaults() defaults['properties'] = properties logtailer = SSHLogTailer(defaults) logtailer.sanityCheck() command = "tail -F /var/log/anylog555 /var/log/anylog1" logtailer.createCommands() self.assertEquals(command,logtailer.hostnames['hostname0']['command'])