From 47d3eee6fe4c75f474bad591b28d0db223a2bc25 Mon Sep 17 00:00:00 2001 From: Brian Warner Date: Sun, 15 Nov 2015 10:33:17 -0800 Subject: [PATCH] server: treat missing moods (from older clients) as "quiet" --- src/wormhole/servers/relay_server.py | 6 +++--- src/wormhole/test/test_server.py | 10 ++++++++++ 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/wormhole/servers/relay_server.py b/src/wormhole/servers/relay_server.py index abea91c..862da9d 100644 --- a/src/wormhole/servers/relay_server.py +++ b/src/wormhole/servers/relay_server.py @@ -318,9 +318,9 @@ class Channel: return (started, "pruney", total_time, None) # ok, both sides closed. figure out the mood - A_mood = A_deallocs[0]["body"] - B_mood = B_deallocs[0]["body"] - mood = "errory" + A_mood = A_deallocs[0]["body"] # maybe None + B_mood = B_deallocs[0]["body"] # maybe None + mood = "quiet" if A_mood == u"happy" and B_mood == u"happy": mood = "happy" if A_mood == u"lonely" or B_mood == u"lonely": diff --git a/src/wormhole/test/test_server.py b/src/wormhole/test/test_server.py index fe8a6b2..59e42c2 100644 --- a/src/wormhole/test/test_server.py +++ b/src/wormhole/test/test_server.py @@ -413,3 +413,13 @@ class Summary(unittest.TestCase): (1, "scary", 40, 9)) self.failUnlessEqual(c._summarize(make_moods("scary", "errory"), 41), (1, "scary", 40, 9)) + + # older clients don't send a mood + self.failUnlessEqual(c._summarize(make_moods(None, None), 41), + (1, "quiet", 40, 9)) + self.failUnlessEqual(c._summarize(make_moods(None, "happy"), 41), + (1, "quiet", 40, 9)) + self.failUnlessEqual(c._summarize(make_moods(None, "happy"), 41), + (1, "quiet", 40, 9)) + self.failUnlessEqual(c._summarize(make_moods(None, "scary"), 41), + (1, "scary", 40, 9))