コード例 #1
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
コード例 #2
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
コード例 #3
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
コード例 #4
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
コード例 #5
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
コード例 #6
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
コード例 #7
0
ファイル: http.py プロジェクト: rgv151/arecibo
def post(request):
    """ Add in a post """
    err = Error()
    err.ip = request.META.get("REMOTE_ADDR", "")
    err.user_agent = request.META.get("HTTP_USER_AGENT", "")

    populate(err, request.POST)
    return render_plain("Error recorded")
コード例 #8
0
ファイル: http.py プロジェクト: pajenterprise/arecibo
def post(request):
    """ Add in a post """
    err = Error()
    err.ip = request.META.get("REMOTE_ADDR", "")
    err.user_agent = request.META.get("HTTP_USER_AGENT", "")

    populate(err, request.POST)
    return render_plain("Error recorded")
コード例 #9
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
コード例 #10
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
コード例 #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 プロジェクト: 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
コード例 #13
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
コード例 #14
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"
コード例 #15
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
コード例 #16
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
コード例 #17
0
    def _setup(self):
        self.project = Project(name="testing")
        self.project.save()

        self.url = ProjectURL(url="http://test.areciboapp.com")
        self.url.project = self.project
        self.url.save()

        self.url = ProjectURL(url="http://www.areciboapp.com")
        self.url.project = self.project
        self.url.save()

        self.error = Error()
        for k, v in break_url("http://test.areciboapp.com/an/other").items():
            setattr(self.error, k, v)
        self.error.save()
コード例 #18
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()
コード例 #19
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()
コード例 #20
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)
コード例 #21
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)
コード例 #22
0
ファイル: mail_django.py プロジェクト: pajenterprise/arecibo
def post(request):
    """ Add in a post """
    log("Processing email message")
    mailobj = mail.InboundEmailMessage(request.raw_post_data)
    to = mailobj.to

    if to in settings.ALLOWED_RECEIVING_ADDRESSES:
        key = settings.ARECIBO_PUBLIC_ACCOUNT_NUMBER
    else:
        key = to.split("-", 1)[1].split("@")[0]
        if key != settings.ARECIBO_PUBLIC_ACCOUNT_NUMBER:
            log("To address (%s, to %s) does not match account number (%s)" %
                (key, to, settings.ARECIBO_PUBLIC_ACCOUNT_NUMBER))
            return

    for content_type, body in mailobj.bodies("text/plain"):
        if mailobj.subject.find(" Broken ") > -1:
            log("Trying to parse body using 404 parser")
            result = parse_404(body, mailobj.subject)
        else:
            log("Trying to parse body using 500 parser")
            result = parse_500(body, mailobj.subject)
        err = Error()
        result["account"] = key
        populate(err, result)

    return render_plain("message parsed")
コード例 #23
0
def send_signal(request, pk):
    error = Error.get(pk)
    if not error.create_signal_sent:
        error.create_signal_sent = True
        error.save()
        error_created.send(sender=error.__class__, instance=error)
        return render_plain("Signal sent")
    return render_plain("Signal not sent")
コード例 #24
0
def error_public_toggle(request, pk):
    error = Error.get(pk)
    if request.method.lower() == "post":
        if error.public:
            error.public = False
        else:
            error.public = True
        error.save()
    return HttpResponseRedirect(reverse("error-view", args=[error.id,]))
コード例 #25
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()
コード例 #26
0
ファイル: test_views.py プロジェクト: Carl4/scale
class TestJobTypesSystemFailuresView(TestCase):
    def setUp(self):
        django.setup()

        self.error = Error(name="Test Error", description="test")
        self.error.save()
        self.job = job_test_utils.create_job(status="FAILED", error=self.error)

    def test_successful(self):
        """Tests successfully calling the system failures view."""

        url = "/job-types/system-failures/"
        response = self.client.generic("GET", url)
        result = json.loads(response.content)

        self.assertEqual(response.status_code, status.HTTP_200_OK)
        self.assertEqual(len(result["results"]), 1)
        self.assertEqual(result["results"][0]["job_type"]["name"], self.job.job_type.name)
        self.assertEqual(result["results"][0]["error"]["name"], self.error.name)
        self.assertEqual(result["results"][0]["count"], 1)
コード例 #27
0
def parse(content_type, body):
    data = body.decode()
    if data.rfind("}") > 0:
        # strip out any crap on the end
        end = data.rfind("}")
        # not sure why i was doing this, i'm sure there
        # was a good reason at one point
        text = data[:end] + "}"
        err = Error()
        json = loads(text, strict=False)
        populate(err, json)
        return True
コード例 #28
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()
コード例 #29
0
def error_view(request, pk):
    error = Error.get(pk)
    if not error.public:
        if not request.user.is_staff:
            return not_allowed(request)

    if not error.read:
        error.read = True
        error.save()

    return direct_to_template(request, "view.html", extra_context={
        "error":error,
        "nav": {"selected": "list"},
        })
コード例 #30
0
ファイル: tests.py プロジェクト: alanjds/arecibo
    def _setup(self):
        self.project = Project(name="testing")
        self.project.save()

        self.url = ProjectURL(url="http://test.areciboapp.com")
        self.url.project = self.project
        self.url.save()

        self.url = ProjectURL(url="http://www.areciboapp.com")
        self.url.project = self.project
        self.url.save()

        self.error = Error()
        for k, v in break_url("http://test.areciboapp.com/an/other").items():
            setattr(self.error, k, v)
        self.error.save()
コード例 #31
0
ファイル: tests.py プロジェクト: pajenterprise/arecibo
 def testCount(self):
     for x in range(0, 1110):
         Error().save(dont_send_signals=True)
     assert count() == 1110
     for x in range(0, 5):
         err = Error(dont_send_signals=True)
         err.priority = 4
         err.save()
     assert count(["priority = ", 4]) == 5
     assert count(["priority = ", None]) == 1110
     assert count() == 1115
コード例 #32
0
ファイル: error.py プロジェクト: sau29/scale
    def create_model(self):
        """Creates an error model representing this job error

        :returns: The error model
        :rtype: :class:`error.models.Error`
        """

        error_model = Error()
        error_model.name = self.name
        error_model.job_type_name = self.job_type_name
        error_model.title = self.title
        error_model.description = self.description
        error_model.category = self.category

        return error_model
コード例 #33
0
ファイル: test_models.py プロジェクト: sau29/scale
    def test_get_job_error(self):
        """Tests successfully calling get_job_error()"""

        job_type_name = 'job_type_1'
        error_model = Error()
        error_model.name = 'error_1'
        error_model.job_type_name = job_type_name
        error_model.title = 'Error 1'
        error_model.description = 'This is a description'
        error_model.category = 'ALGORITHM'
        Error.objects.save_job_error_models(job_type_name, [error_model])

        # Test retrieving error model, which will load it into the cache
        error_model = get_job_error(job_type_name, 'error_1')
        self.assertEqual(error_model.name, 'error_1')
コード例 #34
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
コード例 #35
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
コード例 #36
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
コード例 #37
0
ファイル: tests.py プロジェクト: alanjds/arecibo
 def setUp(self):
     for error in Error.all(): error.delete()
     for notification in Notification.all(): notification.delete()
コード例 #38
0
ファイル: tests.py プロジェクト: pajenterprise/arecibo
 def setUp(self):
     for error in Error.all(): error.delete()
コード例 #39
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
コード例 #40
0
def create_error():
    return Error(timestamp=datetime.now(), timestamp_date=datetime.today())
コード例 #41
0
ファイル: post.py プロジェクト: erikrose/arecibo
def populate(incoming):
    """ Populate the error table with the incoming error """
    # special lookup the account
    err = Error()
    uid = incoming.get("account", "")
    if not settings.ANONYMOUS_POSTING:
        if not uid:
            raise ValueError, "Missing the required account number."

        if str(uid) != settings.ARECIBO_PUBLIC_ACCOUNT_NUMBER:
            raise ValueError, "Account number does not match"

    # special
    if incoming.has_key("url"):
        for k, v in break_url(incoming["url"]).items():
            setattr(err, k, v)

    # check the status codes
    if incoming.has_key("status"):
        status = str(incoming["status"])
        try:
            valid_status(status)
            err.status = status
        except StatusDoesNotExist:
            err.errors += "Status does not exist, ignored.\n"

    # not utf-8 encoded
    for src, dest in [
        ("ip", "ip"),
        ("user_agent", "user_agent"),
        ("uid", "uid"),
        ]:
        actual = incoming.get(src, None)
        if actual is not None:
            setattr(err, dest, str(actual))

    try:
        priority = int(incoming.get("priority", 0))
    except ValueError:
        priority = 0
    err.priority = min(priority, 10)

    # possibly utf-8 encoding
    for src, dest in [
        ("type", "type"),
        ("msg", "msg"),
        ("server", "server"),
        ("traceback", "traceback"),
        ("request", "request"),
        ("username", "username")
        ]:
        actual = incoming.get(src, None)
        if actual is not None:
            try:
                setattr(err, dest, actual.encode("utf-8"))
            except UnicodeDecodeError:
                err.errors += "Encoding error on the %s field, ignored.\n" % src

    # timestamp handling
    if incoming.has_key("timestamp"):
        tmstmp = incoming["timestamp"].strip()
        if tmstmp.endswith("GMT"):
            tmstmp = tmstmp[:-3] + "-0000"
        tme = parsedate(tmstmp)
        if tme:
            try:
                final = datetime(*tme[:7])
                err.error_timestamp = final
                err.error_timestamp_date = final.date()
            except ValueError, msg:
                err.errors += 'Date error on the field "%s", ignored.\n' % msg
コード例 #42
0
ファイル: post.py プロジェクト: pajenterprise/arecibo
def populate(incoming):
    """ Populate the error table with the incoming error """
    # special lookup the account
    err = Error()
    uid = incoming.get("account", "")
    if not settings.ANONYMOUS_POSTING:
        if not uid:
            raise ValueError, "Missing the required account number."

        if str(uid) != settings.ARECIBO_PUBLIC_ACCOUNT_NUMBER:
            raise ValueError, "Account number does not match"

    # special
    if incoming.has_key("url"):
        for k, v in break_url(incoming["url"]).items():
            setattr(err, k, v)

    # check the status codes
    if incoming.has_key("status"):
        status = str(incoming["status"])
        try:
            valid_status(status)
            err.status = status
        except StatusDoesNotExist:
            err.errors += "Status does not exist, ignored.\n"

    # not utf-8 encoded
    for src, dest in [
        ("ip", "ip"),
        ("user_agent", "user_agent"),
        ("uid", "uid"),
    ]:
        actual = incoming.get(src, None)
        if actual is not None:
            setattr(err, dest, str(actual))

    try:
        priority = int(incoming.get("priority", 0))
    except ValueError:
        priority = 0
    err.priority = min(priority, 10)

    # possibly utf-8 encoding
    for src, dest in [("type", "type"), ("msg", "msg"), ("server", "server"),
                      ("traceback", "traceback"), ("request", "request"),
                      ("username", "username")]:
        actual = incoming.get(src, None)
        if actual is not None:
            try:
                setattr(err, dest, actual.encode("utf-8"))
            except UnicodeDecodeError:
                err.errors += "Encoding error on the %s field, ignored.\n" % src

    # timestamp handling
    if "timestamp" in incoming:
        tmstmp = incoming["timestamp"].strip()
        if tmstmp.endswith("GMT"):
            tmstmp = tmstmp[:-3] + "-0000"
        tme = parsedate(tmstmp)
        if tme:
            try:
                final = datetime(*tme[:7])
                err.error_timestamp = final
                err.error_timestamp_date = final.date()
            except ValueError, msg:
                err.errors += 'Date error on the field "%s", ignored.\n' % msg
コード例 #43
0
ファイル: tests.py プロジェクト: alanjds/arecibo
class ErrorTests(TestCase):
    # test the view for writing errors
    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()

    def testLogAdded(self):
        issue = Issue()
        issue.description = "This is a test"
        issue.save()

        assert issue.log_set[0]

    def _setup(self):
        self.project = Project(name="testing")
        self.project.save()

        self.url = ProjectURL(url="http://test.areciboapp.com")
        self.url.project = self.project
        self.url.save()

        self.url = ProjectURL(url="http://www.areciboapp.com")
        self.url.project = self.project
        self.url.save()

        self.error = Error()
        for k, v in break_url("http://test.areciboapp.com/an/other").items():
            setattr(self.error, k, v)
        self.error.save()

    def _issue(self):
        self.issue = Issue()
        self.issue.description = "This is a test"
        self.issue.save()

    def testIssueGroup(self):
        self._setup()

        self._issue()

        group = Group.all()[0]
        self.issue.add_group(group)

        assert group == self.issue.issuegroup_set[0].group
        assert self.issue.issuegroup_set.count() == 1

        assert self.issue == IssueGroup.all().filter("issue = ", self.issue)[0].issue

    def testIssueURL(self):
        self._setup()

        self.issue = Issue()
        self.issue.description = "This is a test"
        self.issue.project = self.project
        self.issue.save()

        assert self.issue.issueprojecturl_set.count() == 2
        assert self.issue.issueprojecturl_set[0].status == "not_fixed"

    def testIssueURLFlexibility(self):
        self._setup()

        self._issue()
        assert self.issue == issue_by_number(self.issue.number)
        assert self.issue == issue_by_number(self.issue.number)

    def testIssueChanged(self):
        self.signal_fired = False
        def signal_fired(instance, old, **kw):
            self.signal_fired = True
        signals.issue_changed.connect(signal_fired, dispatch_uid="issue_changed")
        self._issue()
        self.issue.status = "rejected"
        self.issue.save()
        assert self.signal_fired

    def testIssuePriorityChanged(self):
        self.signal_fired = False
        def signal_fired(instance, old, new, **kw):
            self.signal_fired = True
            assert old in (None, 1)
            assert new in (1, 2)

        signals.issue_priority_changed.connect(signal_fired, dispatch_uid="issue_priority_changed")

        self._issue()
        self.issue.priority = 1
        self.issue.save()
        assert self.signal_fired

        self.signal_fired = False
        self.issue.priority = 2
        self.issue.save()
        assert self.signal_fired

    def testIssueStatusChanged(self):
        self.signal_fired = False
        def signal_fired(instance, old, new, **kw):
            self.signal_fired = True
            assert not old
            assert new == "rejected"

        signals.issue_status_changed.connect(signal_fired, dispatch_uid="issue_status_changed")

        self._issue()
        self.issue.status = "rejected"
        self.issue.save()
        assert self.signal_fired

        self.signal_fired = False
        self.issue.priority = 1
        self.issue.save()
        assert not self.signal_fired
コード例 #44
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()
コード例 #45
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()
コード例 #46
0
ファイル: views.py プロジェクト: robhudson/arecibo
def error_view(request, id):
    error = Error.get(id)
    if not error.read:
        error.read = True
        error.save()
    return direct_to_template(request, "view.html", extra_context={"error":error})
コード例 #47
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})
コード例 #48
0
ファイル: test_models.py プロジェクト: sau29/scale
    def test_save_job_error_models(self):
        """Tests successfully calling save_job_error_models()"""

        job_type_name = 'job_type_1_for_error_test'
        error_model_1 = Error()
        error_model_1.name = 'error_1'
        error_model_1.job_type_name = job_type_name
        error_model_1.title = 'Error 1'
        error_model_1.description = 'This is a description'
        error_model_1.category = 'ALGORITHM'
        error_model_2 = Error()
        error_model_2.name = 'error_2'
        error_model_2.job_type_name = job_type_name

        # Test saving models for the first time
        Error.objects.save_job_error_models(job_type_name,
                                            [error_model_1, error_model_2])
        self.assertEqual(
            Error.objects.filter(job_type_name=job_type_name).count(), 2)

        # Make some changes
        error_model_1.description = 'New description'
        error_model_2.category = 'DATA'

        # Test updating models
        Error.objects.save_job_error_models(job_type_name,
                                            [error_model_1, error_model_2])
        self.assertEqual(
            Error.objects.get(name='error_1').description, 'New description')
        self.assertEqual(Error.objects.get(name='error_2').category, 'DATA')
コード例 #49
0
ファイル: views.py プロジェクト: rootart/arecibo
def error_view(request, pk):
    error = Error.get(pk)
    if not error.read:
        error.read = True
        error.save()
    return direct_to_template(request, "view.html", extra_context={"error": error, "nav": {"selected": "list"}})
コード例 #50
0
class ErrorTests(TestCase):
    # test the view for writing errors
    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()

    def testLogAdded(self):
        issue = Issue()
        issue.description = "This is a test"
        issue.save()

        assert issue.log_set[0]

    def testIssueNumber(self):
        issue = Issue()
        issue.description = "This is a test"
        issue.save()
        assert issue.number == 1

        issue = Issue()
        issue.description = "This is a test"
        issue.save()
        assert issue.number == 2

        old_issue = issue

        issue = Issue()
        issue.description = "This is a test"
        issue.save()
        assert issue.number == 3, issue.number

        old_issue.delete()

        issue = Issue()
        issue.description = "This is a test"
        issue.save()
        assert issue.number == 4

    def _setup(self):
        self.project = Project(name="testing")
        self.project.save()

        self.url = ProjectURL(url="http://test.areciboapp.com")
        self.url.project = self.project
        self.url.save()

        self.url = ProjectURL(url="http://www.areciboapp.com")
        self.url.project = self.project
        self.url.save()

        self.error = Error()
        for k, v in break_url("http://test.areciboapp.com/an/other").items():
            setattr(self.error, k, v)
        self.error.save()

    def _issue(self):
        self.issue = Issue()
        self.issue.description = "This is a test"
        self.issue.save()

    def testIssueGroup(self):
        self._setup()

        self._issue()

        group = Group.all()[0]
        self.issue.add_group(group)

        assert group == self.issue.issuegroup_set[0].group
        assert self.issue.issuegroup_set.count() == 1

        assert self.issue == IssueGroup.all().filter("issue = ",
                                                     self.issue)[0].issue

    def testIssueURL(self):
        self._setup()

        self.issue = Issue()
        self.issue.description = "This is a test"
        self.issue.project = self.project
        self.issue.save()

        assert self.issue.issueprojecturl_set.count() == 2
        assert self.issue.issueprojecturl_set[0].status == "not_fixed"

    def testIssueURLFlexibility(self):
        self._setup()

        self._issue()
        assert self.issue == issue_by_number(self.issue.number)
        assert self.issue == issue_by_number(self.issue.number)

    def testIssueChanged(self):
        self.signal_fired = False

        def signal_fired(instance, old, **kw):
            self.signal_fired = True

        signals.issue_changed.connect(signal_fired,
                                      dispatch_uid="issue_changed")
        self._issue()
        self.issue.status = "rejected"
        self.issue.save()
        assert self.signal_fired

    def testIssuePriorityChanged(self):
        self.signal_fired = False

        def signal_fired(instance, old, new, **kw):
            self.signal_fired = True
            assert old in (None, 1)
            assert new in (1, 2)

        signals.issue_priority_changed.connect(
            signal_fired, dispatch_uid="issue_priority_changed")

        self._issue()
        self.issue.priority = 1
        self.issue.save()
        assert self.signal_fired

        self.signal_fired = False
        self.issue.priority = 2
        self.issue.save()
        assert self.signal_fired

    def testIssueStatusChanged(self):
        self.signal_fired = False

        def signal_fired(instance, old, new, **kw):
            self.signal_fired = True
            assert not old
            assert new == "rejected"

        signals.issue_status_changed.connect(
            signal_fired, dispatch_uid="issue_status_changed")

        self._issue()
        self.issue.status = "rejected"
        self.issue.save()
        assert self.signal_fired

        self.signal_fired = False
        self.issue.priority = 1
        self.issue.save()
        assert not self.signal_fired
コード例 #51
0
ファイル: tests.py プロジェクト: andymckay/arecibo
 def setUp(self):
     for error in Error.all(): error.delete()
コード例 #52
0
ファイル: test_views.py プロジェクト: Carl4/scale
    def setUp(self):
        django.setup()

        self.error = Error(name="Test Error", description="test")
        self.error.save()
        self.job = job_test_utils.create_job(status="FAILED", error=self.error)