server: treat missing moods (from older clients) as "quiet"

This commit is contained in:
Brian Warner 2015-11-15 10:33:17 -08:00
parent 4f0dde9529
commit 47d3eee6fe
2 changed files with 13 additions and 3 deletions

View File

@ -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":

View File

@ -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))