Exemplo n.º 1
0
    def _setup_server_and_clients(self):

        self.server_socket = setup_server()
        mkdir(self.tmp_dir)
        workers, client_sockets = setup_workers(4, self.tmp_dir, self.server_socket, verbose=False)

        return workers, [sock for sock, addr in client_sockets]
Exemplo n.º 2
0
    def test_setup_server(self):
        """setup_server opens a port and listens"""

        self.server_socket = setup_server()
        host, port = self.server_socket.getsockname()
        # Not much to test here, if we get something back it should work
        self.assertGreater(port, 1023)
        # binding to a known port should fail
        self.assertRaises(error, setup_server, 80)
Exemplo n.º 3
0
    def test_setup_server(self):
        """setup_server opens a port and listens"""

        self.server_socket = setup_server()
        host, port = self.server_socket.getsockname()
        # Not much to test here, if we get something back it should work
        self.assertGreater(port, 1023)
        # binding to a known port should fail
        self.assertRaises(error, setup_server, 80)
Exemplo n.º 4
0
    def _setup_server_and_clients(self):

        self.server_socket = setup_server()
        mkdir(self.tmp_dir)
        workers, client_sockets = setup_workers(4, self.tmp_dir,
                                                self.server_socket,
                                                verbose=False)

        return workers, [sock for sock, addr in client_sockets]
Exemplo n.º 5
0
    def test_setup_workers(self):
        """setup_workers starts clients"""

        mkdir(self.tmp_dir)
        self.server_socket = setup_server()
        workers, client_sockets = setup_workers(4, self.tmp_dir, self.server_socket, verbose=False)
        self.assertEqual(len(workers), 4)
        # Try sending some data, return of send should be length of message
        for client_sock, addr in client_sockets:
            self.assertEqual(client_sock.send("Hello"), 5)
Exemplo n.º 6
0
    def test_setup_workers(self):
        """setup_workers starts clients"""

        self.server_socket = setup_server()
        workers, client_sockets = setup_workers(4, self.tmp_dir,
                                                self.server_socket,
                                                verbose=False)
        self.assertEqual(len(workers), 4)
        # Try sending some data, return of send should be length of message
        for client_sock, addr in client_sockets:
            self.assertEqual(client_sock.send("Hello"), 5)
    def test_get_flowgram_distances_on_cluster(self):
        """get_flowgram_distances_on_cluster computes the correct alignment score."""

        self.tmp_dir = mkdtemp(dir="./", suffix="/")
        # setup server and workers
        self.socket = setup_server()
        workers, client_sockets = setup_workers(1,
                                                self.tmp_dir,
                                                self.socket,
                                                verbose=False)
        client_sockets = [a for a, b in client_sockets]
        scores, names, fc = get_flowgram_distances_on_cluster(
            "1", self.flowgram, self.flowgrams, FlowgramContainerArray(),
            {"FZTHQMS01CIW5N": ""}, 1, 1, [1], client_sockets)
        stop_workers(client_sockets)

        self.assertEqual(names, ["FZTHQMS01CIW5N"])
        assert_almost_equal(scores, [[4.95274923, 0.7815385]], decimal=4)
 def test_get_flowgram_distances_on_cluster(self):
     """get_flowgram_distances_on_cluster computes the correct alignment score."""
     
     self.tmp_dir=get_tmp_filename(tmp_dir = "./", suffix="/")
     mkdir(self.tmp_dir)
     #setup server and workers
     self.socket = setup_server()
     workers, client_sockets = setup_workers(1, self.tmp_dir, self.socket,
                                             verbose=False)
     client_sockets = [a for a,b in client_sockets]
     scores, names, fc = get_flowgram_distances_on_cluster("1", self.flowgram,
                                                           self.flowgrams,
                                                           FlowgramContainerArray(),
                                                           {"FZTHQMS01CIW5N":""},
                                                           1, 1, [1],
                                                           client_sockets)
     stop_workers(client_sockets)
 
     self.assertEqual(names, ["FZTHQMS01CIW5N"])
     self.assertFloatEqual(scores, [4.95274923, 0.7815385])