def setUp(self): HTTPAuthBackendTest.setUp(self) # seed http auth with some initial data url = 'http://oldserver.com/foo.html' header = 'Basic realm="Old Protected Space"' self.ask_for_http_auth(url, header) from miro.dl_daemon import daemon class FakeDaemon(daemon.ControllerDaemon): def __init__(self): self.shutdown = False self._setup_httpauth() def send(self, command, callback): # run the command back and forth through pickle to simulate # sending it over the wire. This ensures ojects things like # lists are seen as copies rather than the same object (see # UpdatePasswords for an example). We could use the copy # module, but I (BDK) wanted to simulate what happens between # the downloader and main process as closely as possible. command = pickle.loads(pickle.dumps(command)) command.set_daemon(self) command.action() from miro.dl_daemon.private import httpauth httpauth.update_passwords([]) daemon.LAST_DAEMON = FakeDaemon() globals()['httpauth'] = httpauth # make sure the UpdatePasswords command gets sent now self.runPendingIdles()
def action(self): from miro.dl_daemon.private import httpauth httpauth.update_passwords(*self.args)