def read_data_from_file(filepath: str):
    f = io.FileReader(filepath)
    f.read()

    if f.data is not None:
        update_dataset(f.data)
        update_status(msg.format_status("File read correctly"))
        update_response_text(msg.get_response_text_file_read_ok(f.file_name))

    if f.error is not None:
        update_status(msg.format_status(f.error_msg, error=True))
        update_response_text(msg.get_response_text_error())
Exemple #2
0
def test_filereader_valid_file_returns_data():
    create_test_file(valid_csv, filedata=data)
    f = io.FileReader(valid_csv)
    f.read()
    assert f.data is not None
    remove_test_files()
Exemple #3
0
def test_filereader_empty_file_gives_error():
    create_test_file(empty_file)
    f = io.FileReader(empty_file)
    f.read()
    assert f.error is not None
    remove_test_files()
Exemple #4
0
def test_filereader_returns_error_if_filepath_not_accepted():
    for f in invalid_paths:
        fr = io.FileReader(f)
        assert fr.path_is_accepted is False
Exemple #5
0
def test_filereader_starts_without_data_or_error():
    for f in invalid_paths + invalid_paths:
        assert io.FileReader(f).data is None
        assert io.FileReader(f).error is None
        assert io.FileReader(f).error_msg is None
Exemple #6
0
def test_filereader_retreives_filename_from_path():
    assert io.FileReader("E:/x.csv").file_name == "x.csv"
    assert io.FileReader("E:/data/x.csv").file_name == "x.csv"
Exemple #7
0
def test_filereader_doesnt_accept_invalid_path():
    for f in invalid_paths:
        assert io.FileReader(f).path_is_accepted is False
Exemple #8
0
def test_filereader_accepts_valid_path():
    create_2_main_test_files()
    for f in valid_paths:
        assert io.FileReader(f).path_is_accepted is True
    remove_test_files()
def get_accepted_filetypes():
    return io.FileReader().accepted_filetypes