Ejemplo n.º 1
0
class UserEvents(Api):
    """
    User related application events definition
    """
    class Meta:
        """
        User events meta definition
        """
        name = 'user'

    user_created = Event(parameters=(
        Parameter('uaa_id', int),
        Parameter('username', str),
    ))
    user_deleted = Event(parameters=(Parameter('uaa_id', int), ))
Ejemplo n.º 2
0
class AuthApi(Api):
    user_registered = Event(parameters=[Parameter("username", str)])

    class Meta:
        name = "auth"

    def check_password(self, username: str, password: str):
        return username == "admin" and password == "secret"
Ejemplo n.º 3
0
    class TestApi(Api):
        my_event = Event([Parameter("field", bool)])

        class Meta:
            name = "my.test_api"

        def my_proc(self, field: bool = True) -> str:
            pass
Ejemplo n.º 4
0
class DummyApi(Api):
    my_event = Event([Parameter("field", str)])

    class Meta:
        name = "my.dummy"

    def my_proc(self, field) -> str:
        return "value: {}".format(field)

    def sudden_death(self, n):
        raise SuddenDeathException()

    def random_death(self, n, death_probability=0.5):
        if random() < float(death_probability):
            raise SuddenDeathException()
        return n

    def general_error(self):
        raise RuntimeError("Oh no, there was some kind of error")
Ejemplo n.º 5
0
    class UserApi(Api):
        my_event = Event([Parameter("user", User)])

        class Meta:
            name = "my.user_api"
Ejemplo n.º 6
0
    class TestApi(Api):
        my_event = Event([Parameter("field", bool)])

        class Meta:
            name = "my.test_api"