Esempio n. 1
0
    def _init_server_names_and_ports(self, server_name, server_port):
        last_server_name, last_server_port = prefs.load_last_server()
        server_entries = prefs.load_servers()
        for name, port in server_entries:
            self.server_names.add(name)
            self.server_ports.add(port)
        if server_name:
            self.server_names.add(server_name)
        else:
            server_name = last_server_name
        if server_port:
            self.server_ports.add(server_port)
        else:
            server_port = last_server_port

        namestore = gtk.ListStore(gobject.TYPE_STRING)
        active_index = 0
        for index, name in enumerate(sorted(self.server_names)):
            namestore.append([name])
            if name == server_name:
                active_index = index
        self.server_name_comboboxentry.set_model(namestore)
        self.server_name_comboboxentry.set_text_column(0)
        self.server_name_comboboxentry.set_active(active_index)

        active_index = 0
        portstore = gtk.ListStore(gobject.TYPE_STRING)
        for index, port in enumerate(sorted(self.server_ports)):
            portstore.append([str(port)])
            if port == server_port:
                active_index = index
        self.server_port_comboboxentry.set_model(portstore)
        self.server_port_comboboxentry.set_text_column(0)
        self.server_port_comboboxentry.set_active(active_index)
Esempio n. 2
0
def test_load_servers():
    entries = prefs.load_servers()
    assert entries
    for entry in entries:
        server, port = entry
        assert isinstance(server, str)
        assert isinstance(port, int)
    assert ("localhost", config.DEFAULT_PORT) in entries
Esempio n. 3
0
def test_load_servers():
    entries = prefs.load_servers()
    assert entries
    for entry in entries:
        server, port = entry
        assert type(server) == str
        assert type(port) == int
    assert ("localhost", config.DEFAULT_PORT) in entries
Esempio n. 4
0
def test_load_servers():
    entries = prefs.load_servers()
    assert entries
    for entry in entries:
        server, port = entry
        assert type(server) == str
        assert type(port) == int
    assert ("localhost", config.DEFAULT_PORT) in entries
Esempio n. 5
0
def test_save_server():
    prefs.save_server("localhost", config.DEFAULT_PORT)
    assert ("localhost", config.DEFAULT_PORT) in prefs.load_servers()
Esempio n. 6
0
def test_save_server():
    prefs.save_server("localhost", config.DEFAULT_PORT)
    assert ("localhost", config.DEFAULT_PORT) in prefs.load_servers()