""" Testing the system configuration $Id$ """ # Copyright 2008-2011 eGovMon # This program is distributed under the terms of the GNU General # Public License. # # This file is part of the eGovernment Monitoring # (eGovMon) # # eGovMon is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # eGovMon is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with eGovMon; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, # MA 02110-1301 USA __author__ = "$Author$" __version__ = "$Revision$" __updated__ = "$LastChangedDate$" from sc import * from scerror import * import sys import unittest, doctest result = [] result.append(doctest.testmod(__import__('sc'))) result.append(doctest.testmod(__import__('scerror'))) class TestSequenceFunctions(unittest.TestCase): def setUp(self): self.sc = SystemConfiguration()#rdfmodel='EIAO_SC_test') def testupdatesinsubversion(self): data = set([i.strip() for i in open('./initial.rdf').read().split('\n') if '')] in dir(self.sc) if not isuptodate: sys.stderr.write('Error '+onedata[9:onedata.find('>')]+' is not in the local SystemConfiguration. You need to update /etc/egovmon/initial.rdf\n') self.assert_(isuptodate) def testlocalupdates(self): data = set([i.strip() for i in open(os.path.join(self.sc.homedir,'SystemConfiguration','initial.rdf')).read().split('\n') if '')] for onedata in data] + ['characters','endDocument','endElement','endElementNS','endPrefixMapping','ignorableWhitespace','in_quote','processingInstruction','setDocumentLocator','skippedEntity','startDocument','startElement','startElementNS','startPrefixMapping','value'] for onedata in [i for i in dir(self.sc) if not i.startswith('_')]: isuptodate = onedata in data if not isuptodate: sys.stderr.write('Error '+onedata+' has been added locally to /etc/egovmon/initial.rdf but is not added to subversion. Please do so.\n') #self.assert_(isuptodate) def testwebcachedir(self): webcachedir = self.sc.webcachedirectory import os if not os.path.isdir(webcachedir): sys.stderr.write('ERROR: Could not find the specified directory '+str(webcachedir)+'. Is this correctly specified?\n') self.assert_(os.path.isdir(webcachedir)) def testpasswordsarechanged(self): for password in [self.sc.egovmondbpassword,self.sc.egovmondbpassword]: if password=='removed': sys.stderr.write('ERROR: You need to manually change the passwords in initial.rdf. removed is the default password but you need not a valid password\n') self.assert_(not password=='removed') def testadministratoremailupdates(self): if self.sc.administratoremail in ('maintainers@localhost','removed'): sys.stderr.write('ERROR: You need to manually change the administrator e-mail in initial.rdf. '+self.sc.administratoremail+' is the default password but you need not a valid password\n') self.assert_(not self.sc.administratoremail in ('maintainers@localhost','removed')) def testtemplatedir(self): import os for somefile in [self.sc.crawlerconfigtemplate]: if not os.path.isfile(somefile): sys.stderr.write('ERROR: Could not find the specified file '+str(somefile)+'. Is this correctly specified?\n') self.assert_(os.path.isfile(somefile)) def testconfigdirectory(self): configdirectory = [self.sc.homedir,self.sc.configdirectory,self.sc.loglocation] import os for somedir in configdirectory: if not os.path.isdir(somedir): sys.stderr.write('ERROR: Could not find the specified directory '+str(somedir)+'. Is this correctly specified, if yes you need to create it \n') self.assert_(os.path.isdir(somedir)) def testpermissions(self): import os l = os.popen('ls -l /etc/egovmon/initial.rdf').read().split() correctuser = 'nobody' correctgroup = 'nobody' correctpermission = 'r' user = l[2] group = l[3] permission = l[0][-3] self.assert_(correctuser==user) self.assert_(correctgroup==group) self.assert_(permission==correctpermission) def testcrawlerrdfmodel(self): values = ['eaccchecker','maxmemory','webproxy','webproxyuser','cssmediatype','forcedwcheck','webproxypassword','pagetimeout','systemconfigrdfmodel','maxnotimeout','samplingpolicy','dbcleaner','samplingserver','memcache','siteurlserver','pagetimeout','minpagessampled','smtpserver','administratoremail','webcachedirectory','webcacheurl','loglocation','numberofsamples','minurlcount','minsamplecount','maxurlsfromsite','homedir','javadir','jythondir','wamservers','pdfwamservers','crawlerconfigtemplate','configdirectory'] for value in values: self.assert_(type(str(eval('self.sc.'+value)))==type('')) if __name__ == "__main__": unittest.main()