Exemplo n.º 1
0
def test_save_gqrx():
    tree = ttk.Treeview(columns=("frequency", "mode", "description",
                                 "lockout"),
                        displaycolumns=("frequency", "mode", "description"),
                        show="headings")
    bk = Bookmarks(tree, io=IO())
    bk.bookmarks.csv_save = MagicMock()
    bk.bookmarks.return_value = None
    bk._save_gqrx("test")
    assert (isinstance(bk.bookmarks.row_list, list))
    assert (len(bk.bookmarks.row_list) == 0)
Exemplo n.º 2
0
def test_save_gqrx_mode():
    tree = ttk.Treeview(columns=("frequency", "mode", "description",
                                 "lockout"),
                        displaycolumns=("frequency", "mode", "description"),
                        show="headings")
    value = [u'5,955,000', u'AM', u'found on 18.34 jan 08 2015', u'O']
    tree.insert("", 0, values=value)
    bk = Bookmarks(tree, io=IO())
    bk.bookmarks.csv_save = MagicMock()
    bk.bookmarks.return_value = None
    bk._save_gqrx("test")
    assert (bk.bookmarks.row_list[0][2] in CBB_MODES)
Exemplo n.º 3
0
def bk():
    tree = ttk.Treeview(columns=("frequency", "mode", "description",
                                 "lockout"),
                        displaycolumns=("frequency", "mode", "description"),
                        show="headings")
    value = [u'5,955,000', u'AM', u'found on 18.34 jan 08 2015', u'O']
    bk_list = []
    bk_list.append(value)
    bk = Bookmarks(tree, io=IO())
    bk._insert_bookmarks(bk_list)

    return bk
Exemplo n.º 4
0
def test_import_rig_remote():
    tree = ttk.Treeview(columns=("frequency", "mode", "description",
                                 "lockout"),
                        displaycolumns=("frequency", "mode", "description"),
                        show="headings")
    value = [u'5,955,000', u'AM', u'found on 18.34 jan 08 2015', u'O']
    tree.insert("", 0, values=value)
    bk = Bookmarks(tree, io=IO())
    bk.load = MagicMock()
    bk.load.return_value = "test"
    bk._import_rig_remote("test")
    bk.load.assert_called_once_with("test", ",", silent=False)
Exemplo n.º 5
0
    def __init__(self, config_file):
        """Default config, they will be overwritten when a conf is loaded
        this will be used to write a default config file.
        If the command line specifies a config file we note it in
        alternate_config_file and we use it, otherwise we check for
        the default one.

        :param config_file: config file passed as input argument
        :type config_file: string
        :raises: none
        :returns:none
        """

        self.io = IO()
        self.config_file = config_file
        if not self.config_file:
            self.config = dict.copy(DEFAULT_CONFIG)
        else:
            self.config = {}
Exemplo n.º 6
0
def test_import_gqrx():
    tree = ttk.Treeview(columns=("frequency", "mode", "description",
                                 "lockout"),
                        displaycolumns=("frequency", "mode", "description"),
                        show="headings")
    value = [u'5,955,000', u'AM', u'found on 18.34 jan 08 2015', u'O']
    tree.insert("", 0, values=value)
    bk = Bookmarks(tree, io=IO())
    bk.bookmarks.csv_load = MagicMock()
    bk.bookmarks.csv_load.return_value = "test"
    bk.bookmarks.row_list.append([""])
    bk.bookmarks.row_list.append([""])
    bk.bookmarks.row_list.append([""])
    bk.bookmarks.row_list.append([""])
    bk.bookmarks.row_list.append([""])
    bk.bookmarks.row_list.append([
        "    28800000", " standing spike           ", " Narrow FM           ",
        "      10000", " Untagged"
    ])
    bk._insert_bookmarks = MagicMock()
    bk._import_gqrx("test")
    bk._insert_bookmarks.assert_called_once_with(
        [['28800000', 'FM', 'standing spike']])
Exemplo n.º 7
0
def test_export_rig_remote_bad_attrib():
    bk = Bookmarks("test", io=IO())
    bk._export_panel = MagicMock()
    bk._export_panel.return_value == ""
    with pytest.raises(AttributeError):
        bk.export_rig_remote()
Exemplo n.º 8
0
def test_detect_format():
    bk = Bookmarks("test", io=IO())
    with pytest.raises(InvalidPathError):
        bk._detect_format("")
Exemplo n.º 9
0
def test_export_panel():
    bk = Bookmarks("test", io=IO())
    tkFileDialog.asksaveasfilename = MagicMock()
    tkFileDialog.asksaveasfilename.return_Value = "testfile"
    bk._export_panel() == "testfile"
Exemplo n.º 10
0
def test_bad_file2_csv_save():

    io = IO()
    io.row_list = [2, 2]
    with pytest.raises(csv.Error):
        io.csv_save("/tmp/test.csv", ",")
Exemplo n.º 11
0
def test_bad_file_csv_save():

    io = IO()
    with pytest.raises(TypeError):
        io.csv_save(["/tmp/test.csv", ","])
Exemplo n.º 12
0
def test_good_path_csv_save():

    io = IO()
    io.csv_save("/tmp/test.csv", ",")
Exemplo n.º 13
0
def test_good_path_csv_load():

    io = IO()
    io.csv_load("/tmp/", ",")
Exemplo n.º 14
0
def test_non_existent_path():
    io = IO()
    with pytest.raises(InvalidPathError):
        io._path_check("")
Exemplo n.º 15
0
 def __init__(self, tree, io=IO()):
     self.bookmarks = io
     self.tree = tree