Example #1
0
def test_filter__empty():
    #If filtering twice with an inverted filter the result should be empty
    acc_data = AccountData(data_path1, cat_path)
    acc_data.filter_data("amount", ">=", 300)
    acc_data.filter_data("amount", "<", 300)
    assert (len(acc_data.get_data()) == 0)
    #Tags should also be empty
    assert (len(acc_data.get_tags()) == 0)
    #It should be possible to still call get_timeseries()
    assert (type(acc_data.get_timeseries()) == TimeSeries)
Example #2
0
def test_add():
    acc_data1 = AccountData(data_path1, tag_nested_path)
    acc_data2 = AccountData(data_path2, tag_nested_path)
    sum_data = acc_data1 + acc_data2

    #Categories should not change since both acc_data use the same tag file, though order may change (so sorting it)
    assert (sorted(list(acc_data1.get_tags())) == sorted(
        list(sum_data.get_tags())))
    #Length of get_data should be the sum of both
    assert (len(sum_data.get_data()) == len(acc_data1.get_data()) +
            len(acc_data2.get_data()))
Example #3
0
def test_get_tags_level():
    acc_data = AccountData(data_path1, tag_file=tag_nested_path)
    assert (acc_data.get_tags("==", 0) == ["tag2", "tagABC"])
    assert (acc_data.get_tags(">=", 1) == ["B23", "B", "A", "B1"])
    #Since there are only 2 levels, getting all levels that are less than 3 should give back all tags
    assert (acc_data.get_tags("<", 3) == acc_data.get_tags())
Example #4
0
def test_get_tags():
    acc_data = AccountData(data_path1, tag_file=tag_path)
    assert (sorted(
        acc_data.get_tags()) == ["tag1", "tag2", "tag3", "överföring"])
Example #5
0
def test_filter__tag_list_order():
    acc_data = AccountData(data_path1, tag_file=tag_path)
    #If the order of the tags is different, then it should still yield the same result
    acc_data.filter_data("tags", "==", ["överföring", "tag1"])
    #Should only contain the once that contains all the tags.
    assert (sorted(acc_data.get_tags()) == sorted(["tag1", "överföring"]))
Example #6
0
def test_filter__tag_list():
    acc_data = AccountData(data_path1, tag_file=tag_path)
    acc_data.filter_data("tags", "==", ["tag1", "överföring"])
    #Should only contain the once that contains all the tags.
    assert (sorted(acc_data.get_tags()) == sorted(["tag1", "överföring"]))
Example #7
0
def test_filter__multi_tags():
    #If a data point has multiple tags, those tags should be preserved
    acc_data = AccountData(data_path1, tag_file=tag_path)
    acc_data.filter_data("tags", "==", "överföring")
    assert (len(acc_data.get_tags()) > 1)
Example #8
0
def test_filter__tags():
    acc_data = AccountData(data_path1, tag_file=tag_path)
    acc_data.filter_data("tags", "!=", "tag1")
    assert ("tag1" not in acc_data.get_tags())
    acc_data.filter_data("tags", "==", "tag3")
    assert (acc_data.get_tags() == ["tag3"])
Example #9
0
def test_filter__not_tag_list():
    acc_data = AccountData(data_path1, tag_file=tag_path)
    acc_data.filter_data("tags", "!=", ["tag1", "överföring"])
    #Should still contain överföring, just not any that also tag1
    assert ("överföring" in acc_data.get_tags())
Example #10
0
def test_filter__tag_empty():
    acc_data = AccountData(data_path1, tag_file=tag_path)
    #Should only return those that lack any tags.
    acc_data.filter_data("tags", "==", [])
    assert (acc_data.get_tags() == [])
    assert (len(acc_data.get_data()) > 0)
Example #11
0
def test_filter__multi_tags_any():
    #When filtering "all" with a list, other tags in list should be kept
    acc_data = AccountData(data_path1, tag_file=tag_path)
    acc_data.filter_data("tags", "any", ["tag1", "tag3"])
    assert ("tag1" in acc_data.get_tags())
    assert ("tag3" in acc_data.get_tags())
Example #12
0
def test_filter__multi_tags_all():
    #When filtering "all" with a list, other tags in list should be kept
    acc_data = AccountData(data_path1, tag_file=tag_path)
    acc_data.filter_data("tags", "all", ["överföring"])
    assert ("överföring" in acc_data.get_tags())
    assert (len(acc_data.get_tags()) > 1)
Example #13
0
def test_filter__multi_tags_list():
    #When filtering with a list, only the tags with that litteral list should kept
    acc_data = AccountData(data_path1, tag_file=tag_path)
    acc_data.filter_data("tags", "==", ["överföring"])
    assert (acc_data.get_tags() == ["överföring"])