Did I find the right examples for you? yes no      Crawl my project      Python Jobs

All Samples(2)  |  Call(0)  |  Derive(0)  |  Import(2)

src/n/o/notifier-HEAD/notifier/digest.py   notifier(Download)
from statsd import statsd
 
from notifier.user import UsernameCipher, LANGUAGE_PREFERENCE_KEY
 
# maximum number of threads to display per course
    deactivate the language.
    """
    user_lang = user["preferences"].get(LANGUAGE_PREFERENCE_KEY)
    if user_lang and user_lang in dict(settings.LANGUAGES):
        activate(user_lang)

src/n/o/notifier-HEAD/notifier/tests/test_digest.py   notifier(Download)
 
from notifier.digest import Digest, DigestCourse, DigestItem, DigestThread, render_digest
from notifier.user import LANGUAGE_PREFERENCE_KEY
 
TEST_COURSE_ID = "test_org/test_num/test_course"
    def test_user_lang_pref_supported(self, mock_activate, mock_deactivate):
        user_lang = "fr"
        self.user["preferences"][LANGUAGE_PREFERENCE_KEY] = user_lang
        render_digest(self.user, self.digest, "dummy", "dummy")
        mock_activate.assert_called_with(user_lang)
    def test_user_lang_pref_unsupported(self, mock_activate):
        user_lang = "x-unsupported-lang"
        self.user["preferences"][LANGUAGE_PREFERENCE_KEY] = user_lang
        render_digest(self.user, self.digest, "dummy", "dummy")
        mock_activate.assert_not_called()
 
    @patch("notifier.digest.activate")
    def test_user_lang_pref_absent(self, mock_activate):
        if LANGUAGE_PREFERENCE_KEY in self.user["preferences"]:
            del self.user["preferences"][LANGUAGE_PREFERENCE_KEY]