예제 #1
0
파일: runner.py 프로젝트: dax/jcl
    def test_run(self):
        """Test if run method of JCLComponent is executed"""
        self.has_run_func = False
        def run_func(component_self):
            self.has_run_func = True
            return (False, 0)

        self.runner.pid_file = "/tmp/jcl.pid"
        db_path = tempfile.mktemp("db", "jcltest", DB_DIR)
        db_url = "sqlite://" + db_path
        self.runner.db_url = db_url
        self.runner.config = None
        old_run_func = JCLComponent.run
        JCLComponent.run = run_func
        try:
            self.runner.run()
        finally:
            JCLComponent.run = old_run_func
        self.assertTrue(self.has_run_func)
        Account.dropTable()
        PresenceAccount.dropTable()
        User.dropTable()
        LegacyJID.dropTable()
        model.db_disconnect()
        os.unlink(db_path)
        self.assertFalse(os.access("/tmp/jcl.pid", os.F_OK))
예제 #2
0
파일: runner.py 프로젝트: dax/jcl
 def test__run(self):
     self.runner.pid_file = "/tmp/jcl.pid"
     db_path = tempfile.mktemp("db", "jcltest", DB_DIR)
     db_url = "sqlite://" + db_path
     self.runner.db_url = db_url
     def do_nothing():
         return (False, 0)
     self.runner._run(do_nothing)
     model.db_connect()
     # dropTable should succeed because tables should exist
     Account.dropTable()
     PresenceAccount.dropTable()
     User.dropTable()
     LegacyJID.dropTable()
     model.db_disconnect()
     os.unlink(db_path)
     self.assertFalse(os.access("/tmp/jcl.pid", os.F_OK))
예제 #3
0
파일: runner.py 프로젝트: dax/jmc
 def test__run(self):
     self.runner.pid_file = "/tmp/jmc.pid"
     self.runner.db_url = self.db_url
     def do_nothing():
         return (False, 0)
     self.runner._run(do_nothing)
     model.db_connection_str = self.runner.db_url
     model.db_connect()
     # dropTable should succeed because tables should exist
     Account.dropTable()
     PresenceAccount.dropTable()
     User.dropTable()
     LegacyJID.dropTable()
     MailAccount.dropTable()
     IMAPAccount.dropTable()
     POP3Account.dropTable()
     SMTPAccount.dropTable()
     model.db_disconnect()
     self.assertFalse(os.access("/tmp/jmc.pid", os.F_OK))
예제 #4
0
파일: runner.py 프로젝트: dax/jcl
 def test__run_restart(self):
     self.runner.pid_file = "/tmp/jcl.pid"
     db_path = tempfile.mktemp("db", "jcltest", DB_DIR)
     db_url = "sqlite://" + db_path
     self.runner.db_url = db_url
     self.i = 0
     def restart(self):
         self.i += 1
         yield (True, 0)
         self.i += 1
         yield (False, 0)
         self.i += 1
     restart_generator = restart(self)
     self.runner._run(lambda : restart_generator.next())
     model.db_connect()
     # dropTable should succeed because tables should exist
     Account.dropTable()
     PresenceAccount.dropTable()
     User.dropTable()
     LegacyJID.dropTable()
     model.db_disconnect()
     os.unlink(db_path)
     self.assertFalse(os.access("/tmp/jcl.pid", os.F_OK))
     self.assertEquals(self.i, 2)