Skip to content

Commit

Permalink
Add tests for __iter__
Browse files Browse the repository at this point in the history
  • Loading branch information
Adamtaranto committed Sep 14, 2024
1 parent aeef6e7 commit 9d95e78
Showing 1 changed file with 31 additions and 6 deletions.
37 changes: 31 additions & 6 deletions src/python/tests/test_dunders.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,39 @@ def test_len_after_multiple_counts():
assert len(kmer_table) == 2, "Length should be 2 after adding two unique k-mers"


def test_iter_dunder_method():
"""KmerCountTable should be iterable, yield hash:count pairs"""
pass
# Test iter methods


def test_next_dunder_method():
"""Select next key in generator"""
pass
def test_iterable():
kmer_table = create_sample_kmer_table(3, ["AAA", "TTT", "AAC"])
hash_aaa = kmer_table.hash_kmer("AAA") # 10679328328772601858
hash_ttt = kmer_table.hash_kmer("TTT") # 10679328328772601858
hash_aac = kmer_table.hash_kmer("AAC") # 6579496673972597301

# Collect items from the iterator
items = list(kmer_table)

# Check if the items contain the expected tuples
assert 2 in [
count for _, count in items
], "Counts should be present in the iterated items"
assert 6579496673972597301 in [
key for key, _ in items
], "keys should be present in the iterated items"
assert len(items) == 2, "There should be 2 k-mers in the table"


def test_iter_empty():
kmer_table = oxli.KmerCountTable(ksize=16)

# Collect items from an empty iterator
items = list(kmer_table)

# Ensure that no items are returned from an empty table
assert items == [], "Iterator should be empty for an empty KmerCountTable"


# Test __set__ and __get__


def test_setitem():
Expand Down

0 comments on commit 9d95e78

Please sign in to comment.