Esempio n. 1
0
def test_register_existing_badge():
    b = BadgePrototype("test.testbadge3")
    register_badge(b)

    b2 = BadgePrototype("test.testbadge3")

    register_badge(b2)
Esempio n. 2
0
def test_register_badge():
    b = BadgePrototype("test.testbadge4")
    register_badge(b)

    eq_(get_badge("test.testbadge4"),b)
Esempio n. 3
0
import hashlib

from bottle import route, run, response, request
from gevent.queue import Queue 

from operant import badge
from operant.storage.plain_redis import Redis

# Register the badges you wanna use in your application
# This can be done in a config file
badge.register_badge("testbadge1")

# Setup datastore, we're gonna use redis here...
ds = Redis({"host": "localhost"})

class User(object):
    """ Fake user class implementation """
    def __init__(self, name):
        self.name = name

    def operant_id(self):
        return int(hashlib.md5(self.name).hexdigest(), 16)

@route('/gimme-a-badge')
def gimme():
    response.content_type = "text/plain"
    body = Queue()
    body.put("Went to gimme-a-badge...")

    def _result(received):
        if received:
Esempio n. 4
0
import hashlib

from bottle import route, run, response, request
from gevent.queue import Queue

from operant import badge
from operant.storage.plain_redis import Redis

# Register the badges you wanna use in your application
# This can be done in a config file
badge.register_badge("testbadge1")

# Setup datastore, we're gonna use redis here...
ds = Redis({"host": "localhost"})


class User(object):
    """ Fake user class implementation """
    def __init__(self, name):
        self.name = name

    def operant_id(self):
        return int(hashlib.md5(self.name).hexdigest(), 16)


@route('/gimme-a-badge')
def gimme():
    response.content_type = "text/plain"
    body = Queue()
    body.put("Went to gimme-a-badge...")