Пример #1
0
 def test_start(self):
     port = choose_port()
     with master_context(port=port):
         time.sleep(QUANTUM_SECONDS)
         with mock_client(port) as client:
             client.send(b"START %s p1 p2 p3 p4 p5 p6\n" % PLAYER_HOSTNAME)
             text = client.readline()
Пример #2
0
 def test_start(self):
     port = choose_port()
     with master_context(port=port):
         time.sleep(QUANTUM_SECONDS)
         with mock_client(port) as client:
             client.send(b"START %s p1 p2 p3 p4 p5 p6\n" % PLAYER_HOSTNAME)
             text = client.readline()
Пример #3
0
 def test_exit(self):
     port = choose_port()
     with player_context(port) as proc:
         time.sleep(QUANTUM_SECONDS)
         with mock_client(port, socket.SOCK_DGRAM) as client:
             client.send(b"QUIT\n")
         ret = proc.wait(5)
         self.assertEqual(ret, 0)
Пример #4
0
 def test_exit(self):
     port = choose_port()
     with player_context(port) as proc:
         time.sleep(QUANTUM_SECONDS)
         with mock_client(port, socket.SOCK_DGRAM) as client:
             client.send(b"QUIT\n")
         ret = proc.wait(5)
         self.assertEqual(ret, 0)
Пример #5
0
 def test_start_wrong_host(self):
     port = choose_port()
     with master_context(port=port):
         time.sleep(QUANTUM_SECONDS)
         with mock_client(port) as client:
             client.send(b"START definitely_nonexistent 1 2 3 4 5 6\n")
             line = client.recv(100)
             self.assertIn(b"ERROR", line)
Пример #6
0
    def setUp(self):
        self.PARAMS = 6

        self.parameters = [
            ("ant-waw-01.cdn.eurozet.pl", "/", "8602", "-", str(choose_port()), "yes"),
            ("ant-waw-01.cdn.eurozet.pl", "/", "8602", "-", str(choose_port()), "no"),
            ("ant-waw-01.cdn.eurozet.pl", "/", "8602", "test3.mp3", str(choose_port()), "no"),
            ("stream3.polskieradio.pl", "/", "8904", "-", str(choose_port()), "no"),
        ]

        self.wrong_parameters = [
            ["/", "sdfsdfa", "stream3.polskieradio."],
            ["/lol", "/w/"],
            ["89043284023823099", "-1", "0", "r", "65538", " "],
            ["",],
            ["502300124323423234", "wrr", "0", "-1", "65538", "", " "],
            ["tak", "nie", "", "-", "0", "1"],
        ]
Пример #7
0
    def test_wrong_command(self):
        port = choose_port()
        with master_context((str(port),), stderr=None, stdout=None):
            time.sleep(QUANTUM_SECONDS)
            with mock_client(port) as client:
                client.send(b"WRONG_COMMAND\n")
                line = client.recv(100)
                self.assertIn(b"ERROR", line)

                client.send(b"WRONG_COMMAND\n")
                line = client.recv(100)
                self.assertIn(b"ERROR", line)
Пример #8
0
    def setUp(self):
        self.PARAMS = 6

        self.parameters = [
            ("ant-waw-01.cdn.eurozet.pl", "/", "8602", "-", str(choose_port()),
             "yes"),
            ("ant-waw-01.cdn.eurozet.pl", "/", "8602", "-", str(choose_port()),
             "no"),
            ("ant-waw-01.cdn.eurozet.pl", "/", "8602", "test3.mp3",
             str(choose_port()), "no"),
            ("stream3.polskieradio.pl", "/", "8904", "-", str(choose_port()),
             "no"),
        ]

        self.wrong_parameters = [
            ["/", "sdfsdfa", "stream3.polskieradio."],
            ["/lol", "/w/"],
            ["89043284023823099", "-1", "0", "r", "65538", " "],
            [
                "",
            ],
            ["502300124323423234", "wrr", "0", "-1", "65538", "", " "],
            ["tak", "nie", "", "-", "0", "1"],
        ]
Пример #9
0
 def test_start(self):
     port = choose_port()
     with master_context(port=port):
         time.sleep(QUANTUM_SECONDS)
         with mock_client(port) as client:
             client.send(b"START %s p1 p2 p3 p4 p5 p6\n" % PLAYER_HOSTNAME)
             text = client.recv(100)
             ok, num_str = text.strip().split()
             self.assertEqual(ok, b"OK")
             client_num = int(num_str)
             time.sleep(QUANTUM_SECONDS)
             # TODO: assert that ssh was executed with correct parameters
             # TODO: assert that the client is still running
             client.send(b"QUIT %d\n" % client_num)
             time.sleep(QUANTUM_SECONDS)
             ok = client.recv(100)
             self.assertEqual(ok, b"OK %d\n" % client_num)
Пример #10
0
def master_and_mock_client():
    port = choose_port()
    with master_context(port=port):
        time.sleep(QUANTUM_SECONDS)
        with mock_client(port) as client:
            yield client
Пример #11
0
def master_and_mock_client():
    port = choose_port()
    with master_context(port=port):
        time.sleep(QUANTUM_SECONDS)
        with mock_client(port) as client:
            yield client
Пример #12
0
def VALID_ARGS():
    return [
        ("ant-waw-01.cdn.eurozet.pl", "/", "8602", "-", str(choose_port()), "yes"),
        ("ant-waw-01.cdn.eurozet.pl", "/", "8602", "-", str(choose_port()), "no"),
        ("ant-waw-01.cdn.eurozet.pl", "/", "8602", "test3.mp3", str(choose_port()), "no"),
        ("stream3.polskieradio.pl", "/", "8904", "-", str(choose_port()), "no"),
        ("localhost", "/", str(choose_port()), "-", str(choose_port()), "no"),
        ("localhost", "/", str(choose_port()), "-", str(choose_port()), "yes"),
        ("localhost", "/", str(choose_port()), "test3.mp3", str(choose_port()), "no"),
        ("localhost", "/", str(choose_port()), "test3.mp3", str(choose_port()), "yes"),
        ("stream3.polskieradio.pl", "/", "8904", "test3.mp3", str(choose_port()), "no"),
    ]
Пример #13
0
def VALID_ARGS():
    return [
        ("ant-waw-01.cdn.eurozet.pl", "/", "8602", "-", str(choose_port()),
         "yes"),
        ("ant-waw-01.cdn.eurozet.pl", "/", "8602", "-", str(choose_port()),
         "no"),
        ("ant-waw-01.cdn.eurozet.pl", "/", "8602", "test3.mp3",
         str(choose_port()), "no"),
        ("stream3.polskieradio.pl", "/", "8904", "-", str(choose_port()),
         "no"),
        ("localhost", "/", str(choose_port()), "-", str(choose_port()), "no"),
        ("localhost", "/", str(choose_port()), "-", str(choose_port()), "yes"),
        ("localhost", "/", str(choose_port()), "test3.mp3", str(choose_port()),
         "no"),
        ("localhost", "/", str(choose_port()), "test3.mp3", str(choose_port()),
         "yes"),
        ("stream3.polskieradio.pl", "/", "8904", "test3.mp3",
         str(choose_port()), "no"),
    ]