summaryrefslogtreecommitdiff
path: root/unittests.py
diff options
context:
space:
mode:
authorDavid Pursehouse <david.pursehouse@sonymobile.com>2013-09-11 09:57:16 +0900
committerDavid Pursehouse <david.pursehouse@sonymobile.com>2013-09-11 14:08:23 +0900
commit377d5f2dc91ac045f6148053112f59b4ba768b92 (patch)
tree3755a4d6539fd3b384a83306e51c23ac457fabcf /unittests.py
parent1b646c2b3ada19e3b96f36dd2eef261104917c31 (diff)
downloadpygerrit-377d5f2dc91ac045f6148053112f59b4ba768b92.tar.gz
Fix #3: Don't treat unhandled event types as errors
If an unknown event is received on the event stream, for example if a new event has been added in a later version of Gerrit, do not raise an error. Instead, generate an "UnhandledEvent" event. Change-Id: Ia1902bf4a54883011b7ad3e004f58a2ba8739b21
Diffstat (limited to 'unittests.py')
-rwxr-xr-xunittests.py9
1 files changed, 8 insertions, 1 deletions
diff --git a/unittests.py b/unittests.py
index 1588298..358d7f4 100755
--- a/unittests.py
+++ b/unittests.py
@@ -32,7 +32,7 @@ import unittest
from pygerrit.events import PatchsetCreatedEvent, \
RefUpdatedEvent, ChangeMergedEvent, CommentAddedEvent, \
ChangeAbandonedEvent, ChangeRestoredEvent, \
- DraftPublishedEvent, GerritEventFactory, GerritEvent
+ DraftPublishedEvent, GerritEventFactory, GerritEvent, UnhandledEvent
from pygerrit.client import GerritClient
from setup import REQUIRES as setup_requires
@@ -58,6 +58,7 @@ def _create_event(name, gerrit):
data = open(os.path.join("testdata", name + ".txt"))
json_data = json.loads(data.read().replace("\n", ""))
gerrit.put_event(json_data)
+ return json_data
class TestConsistentDependencies(unittest.TestCase):
@@ -247,6 +248,12 @@ class TestGerritEvents(unittest.TestCase):
self.assertEquals(event.title, "Event title")
self.assertEquals(event.description, "Event description")
+ def test_unhandled_event(self):
+ json_data = _create_event("unhandled-event", self.gerrit)
+ event = self.gerrit.get_event(False)
+ self.assertTrue(isinstance(event, UnhandledEvent))
+ self.assertEquals(event.json, json_data)
+
def test_add_duplicate_event(self):
try:
@GerritEventFactory.register("user-defined-event")