コード例 #1
0
def test_show_href_file_relative(symlink_mock, mkdir_mock):
    path = "../foo.tmp"
    plot = SigPlot()

    plot.show_href(path, '1D')
    assert mkdir_mock.call_count == 1
    assert mkdir_mock.call_args[0][0] == '.'

    assert symlink_mock.call_count == 1

    local_path = 'foo.tmp'
    fpath = os.path.expanduser(os.path.expandvars(path))
    assert symlink_mock.call_args[0] == (fpath, local_path)
コード例 #2
0
def test_show_href_file_absolute_not_already_there(symlink_mock, mkdir_mock):
    path = "~/foo.tmp"
    plot = SigPlot()

    plot.show_href(path, '1D')
    assert mkdir_mock.call_count == 1
    assert mkdir_mock.call_args[0][0] == '.'

    assert symlink_mock.call_count == 1

    local_path = 'foo.tmp'
    fpath = os.path.expanduser(os.path.expandvars(path))
    assert symlink_mock.call_args[0] == (fpath, local_path)
コード例 #3
0
def test_show_href_file_absolute_already_in_cwd():
    plot = SigPlot()

    assert plot.inputs == []

    path = os.path.join(os.getcwd(), "sin.tmp")
    plot.show_href(path, '1D')

    href_obj = {
        "filename": 'sin.tmp',
        "layerType": '1D',
    }
    assert plot.href_obj == href_obj
    assert plot.hrefs == [href_obj]
    assert plot.oldHrefs == [href_obj]
コード例 #4
0
def test_show_href_url():
    plot = SigPlot()
    assert plot.href_obj == {}
    assert plot.hrefs == []

    path = "http://sigplot.lgsinnovations.com/dat/sin.tmp"
    layer_type = "1D"
    plot.show_href(path, layer_type)

    href_obj = {
        "filename": "sin.tmp",
        "layerType": layer_type,
    }
    assert plot.href_obj == href_obj
    assert plot.hrefs == [href_obj]
    assert plot.oldHrefs == [href_obj]

    assert os.path.exists("./sin.tmp")
    os.remove("./sin.tmp")