Skip to content
Permalink
Browse files
2010-10-18 Eric Seidel <eric@webkit.org>
        Reviewed by Adam Barth.

        Correct a bunch of typos in QueueStatusServer
        https://bugs.webkit.org/show_bug.cgi?id=47880

        These are all due to our complete lack of unit testing in QueueStatusServer.
        I added a couple unit tests to cover a few of these fixes, but most of these
        are still only caught by actually running the application.

        * QueueStatusServer/handlers/nextpatch.py:
        * QueueStatusServer/handlers/statusbubble.py:
        * QueueStatusServer/handlers/statusbubble_unittest.py: Added.
        * QueueStatusServer/handlers/updateworkitems.py:
        * QueueStatusServer/model/attachment.py:
        * QueueStatusServer/model/queuepropertymixin.py:
        * QueueStatusServer/model/queuepropertymixin_unittest.py:
        * QueueStatusServer/model/workitems.py:
        * QueueStatusServer/model/workitems_unittest.py: Added.

Canonical link: https://commits.webkit.org/60590@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@70025 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
eseidel committed Oct 19, 2010
1 parent 3710e98 commit df981b6343c223f38aaf46f69372bf627c0880bb
Showing 10 changed files with 136 additions and 7 deletions.
@@ -1,3 +1,24 @@
2010-10-18 Eric Seidel <eric@webkit.org>

Reviewed by Adam Barth.

Correct a bunch of typos in QueueStatusServer
https://bugs.webkit.org/show_bug.cgi?id=47880

These are all due to our complete lack of unit testing in QueueStatusServer.
I added a couple unit tests to cover a few of these fixes, but most of these
are still only caught by actually running the application.

* QueueStatusServer/handlers/nextpatch.py:
* QueueStatusServer/handlers/statusbubble.py:
* QueueStatusServer/handlers/statusbubble_unittest.py: Added.
* QueueStatusServer/handlers/updateworkitems.py:
* QueueStatusServer/model/attachment.py:
* QueueStatusServer/model/queuepropertymixin.py:
* QueueStatusServer/model/queuepropertymixin_unittest.py:
* QueueStatusServer/model/workitems.py:
* QueueStatusServer/model/workitems_unittest.py: Added.

2010-10-18 Adam Barth <abarth@webkit.org>

Disable this test because it's failing on the bots and the authors
@@ -36,7 +36,7 @@

class NextPatch(webapp.RequestHandler):
def get(self, queue_name):
queue = Queue.queue_for_name(queue_name)
queue = Queue.queue_with_name(queue_name)
if not queue:
self.error(404)
return
@@ -42,7 +42,7 @@ class StatusBubble(webapp.RequestHandler):
def _build_bubble(self, queue, attachment):
queue_status = attachment.status_for_queue(queue)
bubble = {
"name": queue.short_name().lowercase(),
"name": queue.short_name().lower(),
"attachment_id": attachment.id,
"queue_position": attachment.position_in_queue(queue),
"state": attachment.state_from_queue_status(queue_status) if queue_status else "none",
@@ -0,0 +1,62 @@
# Copyright (C) 2010 Google, Inc. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above
# copyright notice, this list of conditions and the following disclaimer
# in the documentation and/or other materials provided with the
# distribution.
# * Neither the name of Research in Motion Ltd. nor the names of its
# contributors may be used to endorse or promote products derived from
# this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

import unittest


from handlers.statusbubble import StatusBubble
from model.queues import Queue


class MockAttachment(object):
def __init__(self):
self.id = 1

def status_for_queue(self, queue):
return None

def position_in_queue(self, queue):
return 1


class StatusBubbleTest(unittest.TestCase):
def test_build_bubble(self):
bubble = StatusBubble()
queue = Queue("mac-ews")
attachment = MockAttachment()
bubble_dict = bubble._build_bubble(queue, attachment)
# FIXME: assertDictEqual (in Python 2.7) would be better to use here.
self.assertEqual(bubble_dict["name"], "mac")
self.assertEqual(bubble_dict["attachment_id"], 1)
self.assertEqual(bubble_dict["queue_position"], "1")
self.assertEqual(bubble_dict["state"], "none")
self.assertEqual(bubble_dict["status"], None)


if __name__ == '__main__':
unittest.main()
@@ -54,7 +54,7 @@ def _parse_work_items_string(self, items_string):

def _work_items_from_request(self):
queue_name = self.request.get("queue_name")
queue = Queue.queue_for_name(queue_name)
queue = Queue.queue_with_name(queue_name)
if not queue:
self.response.out.write("\"%s\" is not in queues %s" % (queue_name, Queue.all()))
return None
@@ -108,7 +108,7 @@ def _queue_positions(self):
return self._cached_queue_positions

def _calculate_queue_positions(self):
all_work_items = WorkItems.all().fetch(limit=len(Queues.all()))
all_work_items = WorkItems.all().fetch(limit=len(Queue.all()))
return dict([(items.queue.name(), items.display_position_for_attachment(self.id)) for items in all_work_items])

# FIXME: This is controller/view code and does not belong in a model.
@@ -121,7 +121,7 @@ def _fetch_summary(self):
return summary
summary["bug_id"] = first_status.active_bug_id

for queue in Queues.all():
for queue in Queue.all():
summary[queue.name_with_underscores()] = None
status = QueueStatus.all().filter('queue_name =', queue.name()).filter('active_patch_id =', self.id).order('-date').get()
if status:
@@ -31,7 +31,7 @@ class QueuePropertyMixin(object):
def _queue_getter(self):
# Import at runtime to avoid circular imports
from model.queues import Queue
return Queue.queue_from_name(self.queue_name)
return Queue.queue_with_name(self.queue_name)

def _queue_setter(self, queue):
self.queue_name = queue.name() if queue else None
@@ -42,6 +42,7 @@ def test_queue_property(self):
test_object = ObjectWithQueueName()
mac_ews = Queue("mac-ews")
test_object.queue = mac_ews
self.assertEquals(test_object.queue.name(), "mac-ews")
self.assertEquals(test_object.queue_name, "mac-ews")
test_object.queue = None
self.assertEquals(test_object.queue_name, None)
@@ -40,7 +40,7 @@ def display_position_for_attachment(self, attachment_id):
"""Returns a 1-based index corresponding to the position
of the attachment_id in the queue. If the attachment is
not in this queue, this returns None"""
if attachment_id in attachment_id:
if attachment_id in self.item_ids:
return self.item_ids.index(attachment_id) + 1
return None

@@ -0,0 +1,45 @@
# Copyright (C) 2010 Google, Inc. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above
# copyright notice, this list of conditions and the following disclaimer
# in the documentation and/or other materials provided with the
# distribution.
# * Neither the name of Research in Motion Ltd. nor the names of its
# contributors may be used to endorse or promote products derived from
# this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

import unittest


from model.workitems import WorkItems


class WorkItemsTest(unittest.TestCase):
def test_display_position_for_attachment(self):
items = WorkItems()
items.item_ids = [0, 1, 2]
self.assertEquals(items.display_position_for_attachment(0), 1)
self.assertEquals(items.display_position_for_attachment(1), 2)
self.assertEquals(items.display_position_for_attachment(3), None)


if __name__ == '__main__':
unittest.main()

0 comments on commit df981b6

Please sign in to comment.