"""Settings the tracker has to accept, and still work with. An unrecognised key makes opentracker refuse to start, so a test that it comes up at all is a test that the key was understood. """ import unittest from harness import Tracker, TrackerTestCase, free_port class TcpWorkers(TrackerTestCase): config = "listen.tcp.workers 2\n" def test_the_tracker_serves_with_tcp_workers_asked_for(self): self.assertEqual(self.tracker.announce(self.hash_for("tcpworkers"))[b"complete"], 1) class WorkersOnAListenStatement(unittest.TestCase): def test_a_listen_statement_may_carry_a_worker_count(self): """The option is read off the statement rather than inherited.""" second = free_port() tracker = Tracker("listen.tcp 127.0.0.1:%d workers=2\n" % second) try: self.assertEqual(tracker.announce(b"listenopts\0\0\0\0\0\0\0\0\0\0")[b"complete"], 1) complaints = tracker.stop() self.assertEqual(complaints, [], "the tracker reported:\n" + "\n".join(complaints)) finally: tracker._cleanup()