def testLoad0(self):
     cfg.set('filter', 'domain.0', '')
     cfg.set('filter', 'domain.1', '')
     cfg.set('filter', 'domain.2', '')
     cfg.set('filter', 'domain.3', '')
     cfg.set('filter', 'domain.4', '')
     domain_filter.load()
     self.assertEqual(0, len(domain_filter.g_exdm))
 def testFilter0(self):
     cfg.set('filter', 'domain.0', '')
     cfg.set('filter', 'domain.1', '')
     cfg.set('filter', 'domain.2', '')
     cfg.set('filter', 'domain.3', '')
     cfg.set('filter', 'domain.4', '')
     domain_filter.g_exdm = None                                 # force reload
     self.assertEqual(None, domain_filter.match(''))
     self.assertEqual(None, domain_filter.match('http://abc'))
    def _invoke_dispose(self, minfo, cfp, mlog):
        """ Helper to set 'mlog' config and then invoke dispose() """

        mlog0 = cfg.get('messagelog', 'mlog')
        cfg.cparser.set('messagelog', 'mlog', mlog)
        try:
            self.mlog.dispose(minfo, cfp, self.starttime)
        finally:
            cfg.set('messagelog', 'mlog', mlog0)
    def tearDown(self):
        """ Reset things we have altered. """
        messagelog.mlog = messagelog.MsgLogger()  # reset messagelog.mlog
        cfg.set("indexing", "interval", self.interval0)  # reset configurations
        cfg.set("indexing", "numDoc", self.numDoc0)
        cfg.set("indexing", "max_interval", self.max_interval0)

        os.remove(self.path)  # remove dummy queued msg
    def setUp(self):

        messagelog.mlog = messagelog.MsgLogger()

        # prepare some configuration for this test
        self.interval0 = cfg.get("indexing", "interval")
        self.numDoc0 = cfg.get("indexing", "numDoc")
        self.max_interval0 = cfg.get("indexing", "max_interval")
        cfg.set("indexing", "interval", "3")
        cfg.set("indexing", "numDoc", "5")
        cfg.set("indexing", "max_interval", "360")

        # make dummy queued msg 0.tmp
        self.logdir = cfg.getPath("logs")
        self.path = os.path.join(self.logdir, "0.tmp")
        file(self.path, "wb").close()

        dt0 = datetime.datetime(2000, 1, 1, 10, 00, 0)
        mtime = time.mktime(dt0.timetuple())  # first queued: 2000-1-1 10:00 localtime
        os.utime(self.path, (mtime, mtime))
 def tearDown(self):
     cfg.set('filter', 'domain.0', self.domain0)
     cfg.set('filter', 'domain.1', self.domain1)
     cfg.set('filter', 'domain.2', self.domain2)
     cfg.set('filter', 'domain.3', self.domain3)
     cfg.set('filter', 'domain.4', self.domain4)
 def setUp(self):
     self.domain0 = cfg.set('filter', 'domain.0', '')
     self.domain1 = cfg.set('filter', 'domain.1', '')
     self.domain2 = cfg.set('filter', 'domain.2', '')
     self.domain3 = cfg.set('filter', 'domain.3', '')
     self.domain4 = cfg.set('filter', 'domain.4', '')
     cfg.set('filter', 'domain.0', '.xyz.com')           # domain start by '.'
     cfg.set('filter', 'domain.1', ' abc.com , , def ')  # whitespaces, nothing between ,,
     cfg.set('filter', 'domain.2', ',')                  # lone ,
     cfg.set('filter', 'domain.3', '')                   # blank
     cfg.set('filter', 'domain.4', '')