How to use the pottery.RedisCounter function in pottery

To help you get started, we’ve selected a few pottery examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github brainix / pottery / tests / test_counter.py View on Github external
def test_init(self):
        c = RedisCounter()
        assert c == collections.Counter()
github brainix / pottery / tests / test_counter.py View on Github external
def test_basic_usage(self):
        c = RedisCounter()
        for word in ('red', 'blue', 'red', 'green', 'blue', 'blue'):
            c[word] += 1
        assert c == collections.Counter(blue=3, red=2, green=1)
github brainix / pottery / tests / test_counter.py View on Github external
def test_repr(self):
        'Test RedisCounter.__repr__()'
        c = RedisCounter(('eggs', 'ham'))
        assert repr(c) in {
            "RedisCounter{'eggs': 1, 'ham': 1}",
            "RedisCounter{'ham': 1, 'eggs': 1}",
        }
github brainix / pottery / tests / test_counter.py View on Github external
def test_missing_element_doesnt_raise_keyerror(self):
        c = RedisCounter(('eggs', 'ham'))
        assert c['bacon'] == 0
github brainix / pottery / tests / test_counter.py View on Github external
def test_elements(self):
        c = RedisCounter(a=4, b=2, c=0, d=-2)
        assert sorted(c.elements()) == ['a', 'a', 'a', 'a', 'b', 'b']
github brainix / pottery / tests / test_counter.py View on Github external
def test_update_with_overlapping_dict(self):
        c = RedisCounter(foo=1, bar=1)
        c.update({'bar': 1, 'baz': 3, 'qux': 4})
        assert isinstance(c, RedisCounter)
        assert c == collections.Counter(foo=1, bar=2, baz=3, qux=4)
github brainix / pottery / tests / test_counter.py View on Github external
def test_add(self):
        'Test RedisCounter.__add__()'
        c = RedisCounter(a=3, b=1)
        d = RedisCounter(a=1, b=2)
        e = c + d
        assert isinstance(e, collections.Counter)
        assert e == collections.Counter(a=4, b=3)
github brainix / pottery / tests / test_counter.py View on Github external
def test_in_place_and(self):
        'Test RedisCounter.__iand__()'
        c = RedisCounter(a=4, b=2, c=0, d=-2)
        d = RedisCounter(a=1, b=2, c=3, d=4)
        c &= d
        assert isinstance(c, RedisCounter)
        assert c == collections.Counter(a=1, b=2)
github brainix / pottery / tests / test_counter.py View on Github external
def test_or(self):
        'Test RedisCounter.__or__()'
        c = RedisCounter(a=3, b=1)
        d = RedisCounter(a=1, b=2)
        e = c | d
        assert isinstance(e, collections.Counter)
        assert e == collections.Counter(a=3, b=2)