From 3a4a518c9e16470e49012a42903d67086a181fd4 Mon Sep 17 00:00:00 2001 From: Jean Raby Date: Thu, 16 Feb 2012 22:03:36 +0000 Subject: [PATCH] Cosmetic fixes in preferences.py add a new test to set/get text preferences with chars that must be escaped. Monotone-Parent: 361f4d1d571053d2b3dd474a5d6755ef20cc2851 Monotone-Revision: 72203acde8ebf2eb487bf2f4d7ee94f9c8fcd81a Monotone-Author: jraby@inverse.ca Monotone-Date: 2012-02-16T22:03:36 Monotone-Branch: ca.inverse.sogo --- Tests/Integration/preferences.py | 5 ++-- Tests/Integration/test-preferences.py | 42 +++++++++++++++++++++++++++ 2 files changed, 45 insertions(+), 2 deletions(-) create mode 100644 Tests/Integration/test-preferences.py diff --git a/Tests/Integration/preferences.py b/Tests/Integration/preferences.py index 0d330e4ad..f0bc514f6 100644 --- a/Tests/Integration/preferences.py +++ b/Tests/Integration/preferences.py @@ -53,6 +53,7 @@ class preferences: # should probably be unified... self.preferencesMap = { "SOGoLanguage": "language", + "SOGoTimeZone": "timezone", "SOGoSieveFilters": "sieveFilters", # Vacation stuff @@ -88,9 +89,9 @@ class preferences: self.client.execute (post) - # Raise an exception if the language wasn't properly set + # Raise an exception if the pref wasn't properly set if post.response["status"] != 200: - raise Exception ("failure setting language, (code = %d)" \ + raise Exception ("failure setting prefs, (code = %d)" \ % post.response["status"]) def get(self, preference): diff --git a/Tests/Integration/test-preferences.py b/Tests/Integration/test-preferences.py new file mode 100644 index 000000000..1c065dc01 --- /dev/null +++ b/Tests/Integration/test-preferences.py @@ -0,0 +1,42 @@ +#!/usr/bin/python +from config import hostname, port, username, password + +import preferences +import simplejson +import sogotests +import unittest +import utilities + +class preferencesTest(unittest.TestCase): + + def _setTextPref(self, prefText = None ): + """ set a text preference to a known value """ + self.prefs.set("autoReplyText", prefText) + + # make sure it was set correctly + prefData = self.prefs.get("Vacation") + + try: + self.assertEqual(prefData["autoReplyText"], prefText, + "%s != %s" % (prefData["autoReplyText"], prefText)) + except TypeError as err: + self.fail("Preferences are probably hosed: %s" % (err)) + + def setUp(self): + self.prefs = preferences.preferences() + + def tearDown(self): + self.prefs.set("autoReplyText", "") + + def testSetTextPreferences(self): + """ Set/get a text preference - normal characters""" + + self._setTextPref("defaultText") + + def testSetTextPreferencesWeirdChars(self): + """ Set/get a text preference - weird characters - used to crash on 1.3.12""" + prefText = "weird data \ ' \"; ^" + self._setTextPref(prefText) + +if __name__ == "__main__": + sogotests.runTests()