Esempio n. 1
0
    def test_autodoc(self):
        app = dispatcher.command('/foo')

        @app.respond('baz')
        def baz(request, match):
            """This thing returns baz"""
            return 'baz'

        response = self.send_command('/foo help')
        self.assertContains(response, 'This thing returns baz')
        dispatcher.unregister('/foo')
Esempio n. 2
0
from __future__ import absolute_import

from django.http import JsonResponse

from heatherr.groups.models import Group, Person
from heatherr.models import SlackAccount
from heatherr.views import dispatcher


announce = dispatcher.command('/announce')


@announce.respond(r'^list$')
def list(request, match):
    """
    `list`

    List the known groups.
    """
    groups = Group.objects.filter(
        slackaccount__team_id=request.POST['team_id'])
    person, _ = Person.objects.get_or_create(person_id=request.POST['user_id'])
    if not groups.exists():
        return JsonResponse({
            'text': 'No groups exist'
        })

    return 'Groups:\n%s' % ('\n'.join([
        '- %s%s' % (
            unicode(group),
            (' (member)'