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)
def testInvalidCountProcess(self): """have plugin whose count process doesn't come up""" self.copyPlugin() # F**k with the plugin executable script with open(os.path.join(self.plugin_dest, "test-plugin"), "w") as f: f.write("This is so not executable") plugin.scan_for_plugins() gevent.sleep(.3) self.failIf(len(plugin.plugins_available()) > 0)
def testOnePluginIncorrectJSON(self): """have plugin with invalid json""" # Copy plugin to directory here self.copyPlugin() # Edit json with open(os.path.join(self.plugin_dest, plugin.Plugin.PLUGIN_INFO_FILE), "w") as f: f.write("This is so not some f*****g json") plugin.scan_for_plugins() gevent.sleep(.3) self.failIf(len(plugin.plugins_available()) > 0)
def testOnePluginCorrectJSON(self): """have valid plugin, with a valid count process""" self.copyPlugin() plugin.scan_for_plugins() gevent.sleep(.3) self.failIf(len(plugin.plugins_available()) != 1)
def testNoPlugins(self): """have no plugins""" plugin.scan_for_plugins() # If we've actually started any greenlets, fail self.failIf("plugin" in utils._pools.keys())