コード例 #1
0
    def setUp(self):
        reload(config)
        reload(plugin)
        reload(server)
        reload(utils)
        self.tmpdir = tempfile.mkdtemp(prefix="fetest-")
        with mock.patch('sys.argv', ['b******g', '--config_dir', self.tmpdir]):
            config.init()
        self.plugin_dest = os.path.join(config.get_dir("plugin"), "test-plugin")
        self.server_loop_trigger = gevent.event.Event()
        self.copyPlugin()
        plugin.scan_for_plugins()

        def server_loop():
            server.init()
            utils.spawn_gevent_func("main socket loop", "main", server.msg_loop)
            gevent.sleep()
            self.server_loop_trigger.wait()
            server.shutdown()
        self.server_greenlet = gevent.spawn(server_loop)

        # Start a new socket
        self.test_socket = ClaimFlowTests.ClaimFlowTestSocket(config.get_value("server_address"))
        # Attach to router
        self.test_socket_greenlet = gevent.spawn(self.test_socket.run)
コード例 #2
0
    def setUp(self):
        reload(config)
        reload(server)
        reload(utils)
        self.tmpdir = tempfile.mkdtemp(prefix="fetest-")
        with mock.patch('sys.argv', ['b******g', '--config_dir', self.tmpdir]):
            config.init()
        # Set ping rates REALLY low so these will move quickly
        config.set_value("ping_rate", .01)
        config.set_value("ping_max", .05)
        self.trigger = gevent.event.Event()
        self.server_loop_trigger = gevent.event.Event()

        def server_loop():
            server.init()
            utils.spawn_gevent_func("main socket loop", "main", server.msg_loop)
            gevent.sleep()
            self.server_loop_trigger.wait()
            server.shutdown()

        self.server_greenlet = gevent.spawn(server_loop)

        # Start a new socket
        self.test_socket = HeartbeatTests.HeartbeatTestSocket(config.get_value("server_address"), self.trigger)
        # Attach to router
        self.test_socket_greenlet = gevent.spawn(self.test_socket.run)
コード例 #3
0
 def testConfigFileLoad(self):
     """load config files correctly"""
     config.set_value("server_address", "ipc://wat")
     reload(config)
     with mock.patch('sys.argv', ['b******g', '--config_dir', self.tmpdir]):
         config.init()
         self.failIf(config.get_value("server_address") != "ipc://wat")
コード例 #4
0
 def testDirectoryNoCreation(self):
     """do not create new directory if it doesn't exist, fail out instead"""
     reload(config)
     with mock.patch('sys.argv', ['b******g', '--config_dir', self.tmpdir + "abc", "--config_no_create_dir"]):
         try:
             config.init()
             self.fail("Not throwing exception on missing configuration directories!")
         except RuntimeError:
             pass
コード例 #5
0
 def testHelp(self):
     """help test, should just bail out."""
     reload(config)
     with mock.patch('sys.argv', ['b******g', '-h']):
         try:
             config.init()
             self.fail("Not throwing exception to quit program after help list!")
         except SystemExit:
             pass
コード例 #6
0
 def testInvalidConfigurationKeyLoad(self):
     """throw on screwed config files correctly"""
     config.set_value("server_address", "ipc://wat")
     # Insert bad key!
     with open(os.path.join(config._cdirs["config"], config.CONFIG_FILENAME), "w") as f:
         json.dump({"server_addres": "tcp://127.0.0.1:9389"}, f)
     reload(config)
     with mock.patch('sys.argv', ['b******g', '--config_dir', self.tmpdir]):
         try:
             config.init()
             self.fail("Didn't fail on gibberish json!")
         except KeyError:
             pass
コード例 #7
0
 def testInvalidConfigurationFileLoad(self):
     """throw on screwed config files correctly"""
     config.set_value("server_address", "ipc://wat")
     # Insert gibberish!
     with open(os.path.join(config._cdirs["config"], config.CONFIG_FILENAME), "w") as f:
         f.write("This is so not some f*****g json")
     reload(config)
     with mock.patch('sys.argv', ['b******g', '--config_dir', self.tmpdir]):
         try:
             config.init()
             self.fail("Didn't fail on gibberish json!")
         except ValueError:
             pass
コード例 #8
0
    def setUp(self):
        reload(config)
        reload(plugin)
        reload(server)
        reload(utils)
        self.tmpdir = tempfile.mkdtemp(prefix="fetest-")
        with mock.patch('sys.argv', ['b******g', '--config_dir', self.tmpdir]):
            config.init()
        self.plugin_dest = os.path.join(config.get_dir("plugin"), "test-plugin")
        self.server_loop_trigger = gevent.event.Event()

        def server_loop():
            server.init()
            utils.spawn_gevent_func("main socket loop", "main", server.msg_loop)
            gevent.sleep()
            self.server_loop_trigger.wait()
            server.shutdown()
        self.server_greenlet = gevent.spawn(server_loop)
コード例 #9
0
 def testDirectoryCreation(self):
     """create a new config directory and populate it"""
     with mock.patch('sys.argv', ['b******g', '--config_dir', self.tmpdir]):
         config.init()
     self.failIf(not os.path.exists(config._cdirs["config"]))
     self.failIf(not os.path.exists(config._cdirs["plugin"]))
コード例 #10
0
 def setUp(self):
     reload(config)
     reload(utils)
     self.tmpdir = tempfile.mkdtemp(prefix="fetest-")
     with mock.patch('sys.argv', ['b******g', '--config_dir', self.tmpdir]):
         config.init()