Esempio n. 1
0
def test_is_parsable_good_header():
    """Is a file with a good filename and header accepted?"""

    data = ",".join(ParserImpl.field_names())
    file_prefix = ParserImpl.file_prefix()
    with temp_data(prefix=file_prefix, suffix=".csv", data=data) as file:
        assert ParserImpl.is_file_parsable(file) == True
Esempio n. 2
0
def test_is_parsable_bad_contents():
    """Is a file with bad header contents rejected?"""

    data = "this,is,the,wrong,header"
    with temp_data(prefix=None, suffix=".csv", data=data) as file:
        assert ParserImpl.check_header(file, row=0) == False
        assert ParserImpl.is_file_parsable(file) == False
Esempio n. 3
0
def temp_valid_input_file():

    with temp_data(prefix=ParserImpl.file_prefix(),
                   suffix='.csv',
                   data=FAKE_TRANSACTIONS) as file_name:

        yield file_name
Esempio n. 4
0
def test_parse_reject():
    """Does the `parse` function reject a bad file?"""

    with pytest.raises(ValueError):
        data = "this,is,the,wrong,header"
        with temp_data(prefix=None, suffix=".csv", data=data) as file:
            parser = ParserImpl(file)
            parser.parse()
Esempio n. 5
0
def test_check_header_read_file():
    """Is a good header accepted?"""

    data = ",".join(ParserImpl.field_names())
    file_prefix = ParserImpl.file_prefix()
    with temp_data(prefix=file_prefix, suffix=".csv", data=data) as file:
        assert ParserImpl.check_header(file, header=data, row=0) == True
        assert ParserImpl.is_file_parsable(file) == True
Esempio n. 6
0
def test_is_file_parsable_reject():
    """Does a file with bad contents get rejected?"""

    data = FAKE_USAA_BAD_LINE
    with temp_data(prefix=None, suffix=".csv", data=data) as path:
        assert not Usaa.is_file_parsable(path)
Esempio n. 7
0
def test_is_parsable_bad_filename():
    """Is a bad filename rejected?"""

    with temp_data(prefix="invalid_prefix") as file:
        assert ParserImpl.is_file_parsable(file) == False