def main(args): ''' Main function ''' try: options, arguments = getopt.getopt(args[1:], 'f:nv') except getopt.error: sys.exit(USAGE) database_path = system.get_default_database_path() auto_discover = True for name, value in options: if name == '-f': database_path = value elif name == '-n': auto_discover = False elif name == '-v': CONFIG['verbose'] = 1 if len(arguments) != 1 and len(arguments) != 2: sys.exit(USAGE) DATABASE.set_path(database_path) CONFIG.merge_database(DATABASE.connection()) if len(arguments) == 2: RUNNER_TESTS.update({arguments[0]: [arguments[1]]}) ctx = {'uri': arguments[1]} else: ctx = None deferred = Deferred() deferred.add_callback(lambda param: None) RUNNER_CORE.run(arguments[0], deferred, auto_discover, ctx) POLLER.loop()
def main(args): ''' Main function ''' try: options, arguments = getopt.getopt(args[1:], 'f:n') except getopt.error: sys.exit('Usage: %s [-n] [-f database] test [negotiate_uri]' % args[0]) if len(arguments) != 1 and len(arguments) != 2: sys.exit('Usage: %s [-n] [-f database] test [negotiate_uri]' % args[0]) database_path = system.get_default_database_path() auto_rendezvous = True for name, value in options: if name == '-f': database_path = value elif name == '-n': auto_rendezvous = False DATABASE.set_path(database_path) CONFIG.merge_database(DATABASE.connection()) if len(arguments) == 2: RUNNER_TESTS.update({arguments[0]: [arguments[1]]}) ctx = {'uri': arguments[1]} else: ctx = None RUNNER_CORE.run(arguments[0], lambda *args: None, auto_rendezvous, ctx) POLLER.loop()
def got_response(self, stream, request, response): ''' Invoked when the response is received ''' if response.code != '200': logging.info('runner_rendezvous: bad response') stream.close() return message = json.load(response.body) RUNNER_TESTS.update(message['available']) RUNNER_UPDATES.update(message['update']) logging.info('runner_rendezvous: rendezvous complete') stream.close()
def test_bittorrent_invokation_good(self): ''' Verify run_queue() behavior when bittorrent is invoked and there is a URI for bittorrent ''' # # The whole point of this test is to make sure that # bittorrent.run() is invoked when privacy is OK and # we have a negotiate URI. We also want to check that # the "testdone" event is subscribed after run_queue(), # i.e. that someone is waiting for the event that # signals the end of the test. # # We need to ensure bittorrent.run() is invoked bittorrent_run = [0] def on_bittorrent_run(poller, conf): ''' Register bittorrent.run() invokation ''' # pylint: disable=W0613 bittorrent_run[0] += 1 # Setup (we will restore that later) saved_run = bittorrent.run bittorrent.run = on_bittorrent_run RUNNER_TESTS.update({'bittorrent': '/'}) CONFIG.conf['privacy.can_publish'] = 1 CONFIG.conf['privacy.informed'] = 1 CONFIG.conf['privacy.can_collect'] = 1 core = RunnerCore() core.queue.append(('bittorrent', Deferred(), None)) core.run_queue() # Restore bittorrent.run = saved_run RUNNER_TESTS.update({}) # Worked as expected? self.assertTrue(bittorrent_run[0]) self.assertTrue(NOTIFIER.is_subscribed("testdone")) # # Clear the "testdone" because otherwise it will # screw up other tests and we don't want that # NOTIFIER.publish("testdone")