コード例 #1
0
ファイル: tests.py プロジェクト: pajenterprise/arecibo
 def testGroupDelete(self):
     c = Client()
     c.post(reverse("error-post"), data)
     assert Group.all().count() == 1, "Got %s groups, not 1" % Group.all().count()
     assert Error.all().count() == 1
     Error.all()[0].delete()
     assert Group.all().count() == 0
コード例 #2
0
ファイル: tests.py プロジェクト: robhudson/arecibo
    def testBasic(self):
        c = Client()
        assert not Error.all().count()
        data = {
            "account": settings.ARECIBO_PUBLIC_ACCOUNT_NUMBER,
            "priority": 4,
            "user_agent": "Mozilla/5.0 (Macintosh; U; Intel Mac OS X...",
            "url": "http://badapp.org/-\ufffdwe-cant-lose",
            "uid": "123124123123",
            "ip": "127.0.0.1",    
            "type": "Test from python",
            "status": "403",
            "server": "Test Script", 
            "request": """This is the bit that goes in the request""",
            "username": "******",
            "msg": """
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut 
labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris 
nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit 
esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in 
culpa qui officia deserunt mollit anim id est laborum
""",
            "traceback": """Traceback (most recent call last",:
  File "<stdin>", line 1, in <module>
ZeroDivisionError: integer division or modulo by zero  df
""",}
        res = c.post(reverse("post"), data)
        assert Error.all().count() == 1
コード例 #3
0
ファイル: tests.py プロジェクト: pajenterprise/arecibo
 def testUnicodeTraceback(self):
     c = Client()
     assert not Error.all().count()
     ldata = data.copy()
     ldata["traceback"] = "ɷo̚حٍ"
     c.post(reverse("error-post"), ldata)
     assert Error.all().count() == 1
コード例 #4
0
ファイル: tests.py プロジェクト: pajenterprise/arecibo
 def testNoPriority(self):
     c = Client()
     assert not Error.all().count()
     ldata = data.copy()
     del ldata["priority"]
     c.post(reverse("error-post"), ldata)
     assert Error.all().count() == 1
コード例 #5
0
ファイル: tests.py プロジェクト: alanjds/arecibo
 def testNoPriority(self):
     c = Client()
     assert not Error.all().count()
     ldata = data.copy()
     del ldata["priority"]
     c.post(reverse("error-post"), ldata)
     assert Error.all().count() == 1
コード例 #6
0
ファイル: tests.py プロジェクト: alanjds/arecibo
 def testGroupDelete(self):
     c = Client()
     c.post(reverse("error-post"), data)
     assert Group.all().count() == 1, "Got %s groups, not 1" % Group.all().count()
     assert Error.all().count() == 1
     Error.all()[0].delete()
     assert Group.all().count() == 0
コード例 #7
0
ファイル: tests.py プロジェクト: andymckay/arecibo
 def testNoNotification(self):
     c = Client()
     assert not Error.all().count()
     data = test_data.copy()
     data["priority"] = 6
     c.post(reverse("error-post"), data)
     assert data["priority"] > 5, data["priority"]
     assert Error.all().count() == 1
     assert Notification.all().count() == 0
コード例 #8
0
ファイル: tests.py プロジェクト: pajenterprise/arecibo
 def testNoNotification(self):
     c = Client()
     assert not Error.all().count()
     data = test_data.copy()
     data["priority"] = 6
     c.post(reverse("error-post"), data)
     assert data["priority"] > 5, data["priority"]
     assert Error.all().count() == 1
     assert Notification.all().count() == 0
コード例 #9
0
ファイル: tests.py プロジェクト: pajenterprise/arecibo
    def testBasic(self):
        c = Client()
        assert not Error.all().count()
        c.post(reverse("error-post"), test_data)
        assert test_data["priority"] < 5, test_data["priority"]
        assert Error.all().count() == 1

        c.post(reverse("error-post"), test_data)
        assert test_data["priority"] < 5, test_data["priority"]
        assert Error.all().count() == 2
コード例 #10
0
ファイル: tests.py プロジェクト: andymckay/arecibo
    def testBasic(self):
        c = Client()
        assert not Error.all().count()
        c.post(reverse("error-post"), test_data)
        assert test_data["priority"] < 5, test_data["priority"]
        assert Error.all().count() == 1

        c.post(reverse("error-post"), test_data)
        assert test_data["priority"] < 5, test_data["priority"]
        assert Error.all().count() == 2
コード例 #11
0
ファイル: tests.py プロジェクト: pajenterprise/arecibo
 def testBrowser(self):
     c = Client()
     assert not Error.all().count()
     ldata = data.copy()
     ldata["user_agent"] = "Mozilla/5.0 (compatible; Konqueror/3.5; Linux; X11; de) KHTML/3.5.2 (like Gecko) Kubuntu 6.06 Dapper"
     c.post(reverse("error-post"), ldata)
     assert Error.all().count() == 1
     assert Error.all()[0].user_agent_short == "Konqueror"
     assert Error.all()[0].user_agent_parsed == True
     assert Error.all()[0].operating_system == "Linux"
コード例 #12
0
ファイル: tests.py プロジェクト: alanjds/arecibo
 def testBrowser(self):
     c = Client()
     assert not Error.all().count()
     ldata = data.copy()
     ldata["user_agent"] = "Mozilla/5.0 (compatible; Konqueror/3.5; Linux; X11; de) KHTML/3.5.2 (like Gecko) Kubuntu 6.06 Dapper"
     c.post(reverse("error-post"), ldata)
     assert Error.all().count() == 1
     assert Error.all()[0].user_agent_short == "Konqueror"
     assert Error.all()[0].user_agent_parsed == True
     assert Error.all()[0].operating_system == "Linux"
コード例 #13
0
ファイル: tests.py プロジェクト: pajenterprise/arecibo
    def testGroup(self):
        c = Client()
        c.post(reverse("error-post"), data)
        assert Group.all().count() == 1, "Got %s groups, not 1" % Group.all().count()
        c.post(reverse("error-post"), data)
        assert Group.all().count() == 1
        new_data = data.copy()
        new_data["status"] = 402
        c.post(reverse("error-post"), new_data)
        assert Group.all().count() == 2

        # and test similar
        assert not Error.all()[2].get_similar()
        assert len(Error.all()[1].get_similar()) == 1
        assert len(Error.all()[1].get_similar()) == 1
コード例 #14
0
ファイル: tests.py プロジェクト: alanjds/arecibo
    def testGroup(self):
        c = Client()
        c.post(reverse("error-post"), data)
        assert Group.all().count() == 1, "Got %s groups, not 1" % Group.all().count()
        c.post(reverse("error-post"), data)
        assert Group.all().count() == 1
        new_data = data.copy()
        new_data["status"] = 402
        c.post(reverse("error-post"), new_data)
        assert Group.all().count() == 2

        # and test similar
        assert not Error.all()[2].get_similar()
        assert len(Error.all()[1].get_similar()) == 1
        assert len(Error.all()[1].get_similar()) == 1
コード例 #15
0
ファイル: listeners.py プロジェクト: rootart/arecibo
def default_grouping(instance, **kw):
    """ Given an error, see if we can fingerprint it and find similar ones """
    # prevent an infinite loop
    log("Firing signal: default_grouping")
    if instance.group:
        return

    hsh = generate_key(instance)
    if hsh:
        digest = hsh.hexdigest()
        try:
            created = False
            group = Group.all().filter("uid = ", digest)[0]
            group.count = Error.all().filter("group = ", group).count() + 1
            group.save()
        except IndexError:
            created = True
            group = Group()
            group.uid = digest
            group.count = 1
            group.save()

        instance.group = group
        instance.save()

        if created:
            signals.group_assigned.send(sender=group.__class__, instance=group)
コード例 #16
0
ファイル: tests.py プロジェクト: alanjds/arecibo
 def setUp(self):
     for issue in Issue.all(): issue.delete()
     for log in Log.all(): log.delete()
     for comment in Comment.all(): comment.delete()
     for group in Group.all(): group.delete()
     for error in Error.all(): error.delete()
     for project in Project.all(): project.delete()
コード例 #17
0
 def setUp(self):
     for error in Error.all():
         error.delete()
     for group in Group.all():
         group.delete()
     for project in Project.all():
         project.delete()
コード例 #18
0
def default_grouping(instance, **kw):
    """ Given an error, see if we can fingerprint it and find similar ones """
    # prevent an infinite loop
    log("Firing signal: default_grouping")
    if instance.group:
        return

    hsh = generate_key(instance)
    if hsh:
        digest = hsh.hexdigest()
        try:
            created = False
            group = Group.all().filter("uid = ", digest)[0]
            group.count = Error.all().filter("group = ", group).count() + 1
            group.save()
        except IndexError:
            created = True
            group = Group()
            group.uid = digest
            group.count = 1
            group.save()

        instance.group = group
        instance.save()

        if created:
            signals.group_assigned.send(sender=group.__class__, instance=group)
コード例 #19
0
ファイル: tests.py プロジェクト: pajenterprise/arecibo
 def setUp(self):
     for error in Error.all():
         error.delete()
     for notification in Notification.all():
         notification.delete()
     for user in AppUser.all():
         user.delete()
     for issue in Issue.all():
         issue.delete()
コード例 #20
0
 def setUp(self):
     for issue in Issue.all():
         issue.delete()
     for log in Log.all():
         log.delete()
     for comment in Comment.all():
         comment.delete()
     for group in Group.all():
         group.delete()
     for error in Error.all():
         error.delete()
     for project in Project.all():
         project.delete()
コード例 #21
0
ファイル: utils.py プロジェクト: alanjds/arecibo
def count(*filters):
    count = 0

    query = Error.all(keys_only=True)
    for k, v in filters:
        query = query.filter(k, v)

    query = query.order('__key__')

    while count % max_fetch == 0:
        current_count = query.count()
        if current_count == 0:
            break
        count += current_count

        if current_count == max_fetch:
            last_key = query.fetch(1, max_fetch - 1)[0]
            query = query.filter('__key__ > ', last_key)

    return count
コード例 #22
0
def count(*filters):
    count = 0

    query = Error.all(keys_only=True)
    for k, v in filters:
        query = query.filter(k, v)

    query = query.order('__key__')

    while count % max_fetch == 0:
        current_count = query.count()
        if current_count == 0:
            break
        count += current_count

        if current_count == max_fetch:
            last_key = query.fetch(1, max_fetch - 1)[0]
            query = query.filter('__key__ > ', last_key)

    return count
コード例 #23
0
ファイル: tests.py プロジェクト: andymckay/arecibo
 def setUp(self):
     for error in Error.all(): error.delete()
コード例 #24
0
ファイル: views.py プロジェクト: robhudson/arecibo
def errors_list(request):
    errors = Error.all().order("-timestamp")
    paginated = Paginator(errors, 50)
    page = get_page(request, paginated)
    return direct_to_template(request, "list.html", extra_context={"page":page})
コード例 #25
0
ファイル: tests.py プロジェクト: alanjds/arecibo
 def setUp(self):
     for error in Error.all(): error.delete()
     for notification in Notification.all(): notification.delete()
コード例 #26
0
ファイル: tests.py プロジェクト: pajenterprise/arecibo
 def setUp(self):
     for error in Error.all(): error.delete()
コード例 #27
0
ファイル: tests.py プロジェクト: pajenterprise/arecibo
 def testBasic(self):
     c = Client()
     assert not Error.all().count()
     c.post(reverse("error-post"), data)
     assert Error.all().count() == 1
コード例 #28
0
ファイル: tests.py プロジェクト: alanjds/arecibo
 def testBasic(self):
     c = Client()
     assert not Error.all().count()
     c.post(reverse("error-post"), data)
     assert Error.all().count() == 1
コード例 #29
0
ファイル: tests.py プロジェクト: andymckay/arecibo
 def setUp(self):
     for error in Error.all(): error.delete()
     for notification in Notification.all(): notification.delete()
     for user in AppUser.all(): user.delete()
     for issue in Issue.all(): issue.delete()
コード例 #30
0
ファイル: tests.py プロジェクト: alanjds/arecibo
 def setUp(self):
     for error in Error.all(): error.delete()
     for group in Group.all(): group.delete()
     for project in Project.all(): project.delete()