<commit_before>from bukkit import Collection


def test_creation():
    buckets = Collection(rate=5, limit=23, timeout=31, clock=lambda: 0)
    assert buckets.rate == 5
    assert buckets.limit == 23
    assert buckets.timeout == 31
    assert buckets.head_node.prev_node is buckets.tail_node
    assert buckets.tail_node.next_node is buckets.head_node<commit_msg>Make sure getting buckets and checking for their presence work.<commit_after>from bukkit import Collection


def test_creation():
    buckets = Collection(rate=5, limit=23, timeout=31, clock=lambda: 0)
    assert buckets.rate == 5
    assert buckets.limit == 23
    assert buckets.timeout == 31
    assert buckets.head_node.prev_node is buckets.tail_node
    assert buckets.tail_node.next_node is buckets.head_node


def test_contains():
    buckets = Collection(rate=5, limit=23, timeout=31, clock=lambda: 0)

    assert len(buckets.node_map) == 0
    assert 'thingy' not in buckets
    buckets.consume('thingy', 5)
    assert len(buckets.node_map) == 1
    assert 'thingy' in buckets


def test_get():
    buckets = Collection(rate=5, limit=23, timeout=31, clock=lambda: 0)

    try:
        buckets['thingy']
        assert False, "Should not be able to look up 'thingy'"
    except IndexError, exc:
        assert str(exc) == "No such bucket: 'thingy'"

    buckets.consume('thingy', 5)
    assert buckets['thingy'].tokens == 18
{'fraction_non_alphanumeric': 0.10530085959885387, 'fraction_numerical': 0.02865329512893983, 'mean_word_length': 3.817241379310345, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4790365', 'n_tokens_mistral': 481, 'n_tokens_neox': 423, 'n_words': 125}