Beispiel #1
0
def test_transaction_fields():
    """Are the USAA columns mapped to the TransactionColumns?

    This is done to standardize the final parsed history.
    """

    standard_col_headers = [c.name for c in TransactionColumns]
    for usaa, ours in Usaa.field_2_transaction().items():
        assert usaa in Usaa.field_names()
        assert ours in standard_col_headers
Beispiel #2
0
def test_get_field_amount():
    """Is an amount parsed correctly for a line?

    NB the 'amount' column is used to validate an input file, so it should be tested
    """

    # MAGIC should match the fake value
    expected = Decimal('123.45')
    assert expected == Usaa.get_field(FAKE_USAA_GOOD_LINE_PLUS,
                                      Usaa._AMOUNT_COL_NAME)
Beispiel #3
0
def test_get_field_date():
    """Is a date parsed correctly for a line?

    NB the 'date' column is used to validate an input file, so it should be tested
    """

    # MAGIC should match the fake value
    expected = datetime.datetime.strptime("01/11/2020", "%m/%d/%Y").date()
    assert expected == Usaa.get_field(FAKE_USAA_GOOD_LINE_PLUS,
                                      Usaa._DATE_COL_NAME)
Beispiel #4
0
def test_init_fixture(usaa_file_fixture):
    """Does initialization with the fixture succeed?"""

    Usaa(usaa_file_fixture)
Beispiel #5
0
def test_init():
    """Does initialization succeed?"""

    with usaa_file() as path:
        Usaa(path)
Beispiel #6
0
def usaa_instance(usaa_file_fixture):
    """An instance of Usaa."""

    yield Usaa(usaa_file_fixture)
Beispiel #7
0
def test_run_parse_checks_amount_col():
    """Does a bad debit/credit value get rejected?"""

    path = "FAKE_PATH_FOR_TESTING"
    assert not Usaa._run_parse_checks(FAKE_USAA_BAD_AMOUNT, path, LOGGER)
Beispiel #8
0
def test_run_parse_checks_date_col():
    """Does a bad date value get rejected?"""

    path = "FAKE_PATH_FOR_TESTING"
    assert not Usaa._run_parse_checks(FAKE_USAA_BAD_DATE, path, LOGGER)
Beispiel #9
0
def test_run_parse_checks_col_count():
    """Does a bad column count get rejected?"""

    path = "FAKE_PATH_FOR_TESTING"
    assert not Usaa._run_parse_checks(FAKE_USAA_EXTRA_COL, path, LOGGER)
    assert not Usaa._run_parse_checks(FAKE_USAA_MISSING_COL, path, LOGGER)
Beispiel #10
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)
Beispiel #11
0
def test_is_file_parsable_bbt(bbt_file_fixture):
    """Does a file meant for another parser get rejected?"""

    assert not Usaa.is_file_parsable(bbt_file_fixture)
Beispiel #12
0
def test_is_file_parsable(usaa_file_fixture):
    """Does a good file pass the check?"""

    assert Usaa.is_file_parsable(usaa_file_fixture)
Beispiel #13
0
def test_check_date_reject():
    """Does a bad date value fail?"""

    assert not Usaa.check_date_column(FAKE_USAA_BAD_LINE)
Beispiel #14
0
def test_check_date():
    """Does a good date pass?"""

    assert Usaa.check_date_column(FAKE_USAA_GOOD_LINE_PLUS)
Beispiel #15
0
def test_check_amount_reject():
    """Does a bad amount value fail?"""

    assert not Usaa.check_amount_column(FAKE_USAA_BAD_LINE)
Beispiel #16
0
def test_check_amount():
    """Does a good amount value pass?"""

    assert Usaa.check_amount_column(FAKE_USAA_GOOD_LINE_PLUS)
    assert Usaa.check_amount_column(FAKE_USAA_GOOD_LINE_MINUS)