# Copyright 2005, 2006 EIAO Consoritum # This program is distributed under the terms of the GNU General # Public License. # # This file is part of the European Internet Accessibility Observatory # (EIAO) # # EIAO 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. # # EIAO 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 EIAO; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, # MA 02110-1301 USA __author__ = "Morten Goodwin Olsen" __maintainer__ = "Nils Ulltveit-Moe" __version__ = 0.1 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 testwebcachedir(self): webcachedir = self.sc.webcachedirectory import os self.assert_(os.path.isdir(webcachedir)) def testpasswordsarechanged(self): password = self.sc.urlreppassword if password=='removed': sys.stderr.write('You need to manually change the passwords in initial.rdf. removed is not a valid password\n') self.assert_(not password=='removed') def testtemplatedir(self): templatefile = self.sc.crawlerconfigtemplate import os self.assert_(os.path.isfile(templatefile)) def testconfigdirectory(self): configdirectory = self.sc.configdirectory import os self.assert_(os.path.isdir(configdirectory)) def testcrawlerrdfmodel(self): self.assert_(self.sc.crawlerrdfmodel) def testremovetoomuch(self): ex = False try: self.sc.removeProduct(None,None,None) except NotEnoughInformationError: ex = True self.assert_(ex) ex = False try: self.sc.removeProduct(hashvalue=None,productname='something',version=None) except NotEnoughInformationError: ex = True self.assert_(ex) def testinvalidurl(self): var = self.sc.removeStartUrl('http://www.eiao.net/rdf/configdirectory', 'http://www.eiao.net/rdf/') self.assert_(var == 'configdirectory') fail = False try: self.sc.removeStartUrl('http://www.eiao.net/configdirectory', 'http://www.eiao.net/rdf/') except InvalidURLError: fail = True self.assert_(fail) fail = False try: self.sc.removeStartUrl('http://www.eiao.net/rdf/configdirectory', 'www.eiao.net/rdf/') except InvalidURLError: fail = True self.assert_(fail) fail = False try: self.sc.removeStartUrl('www.eiao.net/rdf/configdirectory', 'http://www.eiao.net/rdf/') except InvalidURLError: fail = True self.assert_(fail) if __name__ == "__main__": unittest.main()