示例#1
0
 def test_user_ruleset_user_no_pref(self):
     self.conf["allow_user_rules"] = True
     server = pad.server.Server(("0.0.0.0", 783), "/dev/null",
                                "/etc/spamassassin/")
     with patch("pad.server.os.path.exists", return_value=False):
         result = server.get_user_ruleset(user="******")
     self.assertEqual(result, self.mainset)
示例#2
0
 def test_user_ruleset_user(self):
     self.conf["allow_user_rules"] = True
     server = pad.server.Server(("0.0.0.0", 783), "/dev/null",
                                "/etc/spamassassin/")
     with patch("pad.server.os.path.exists", return_value=True):
         result = server.get_user_ruleset(user="******")
     parser = self.mock_parser.return_value
     self.assertEqual(result, parser.get_ruleset.return_value)
示例#3
0
    def test_user_ruleset_user_cached(self):
        self.conf["allow_user_rules"] = True
        server = pad.server.Server(("0.0.0.0", 783), "/dev/null",
                                   "/etc/spamassassin/")
        cached_result = Mock()
        server._user_rulesets["alex"] = cached_result

        result = server.get_user_ruleset(user="******")
        self.assertEqual(result, cached_result)
示例#4
0
 def test_user_ruleset_user_file_parsed(self):
     self.conf["allow_user_rules"] = True
     server = pad.server.Server(("0.0.0.0", 783), "/dev/null",
                                "/etc/spamassassin/")
     with patch("pad.server.os.path.exists", return_value=True):
         result = server.get_user_ruleset(user="******")
     parser = self.mock_parser.return_value
     parser.parse_file.assert_called_with(
         "/home/alex/.spamassassin/user_prefs"
     )
示例#5
0
 def test_user_ruleset_user_not_allowed(self):
     server = pad.server.Server(("0.0.0.0", 783), "/dev/null",
                                "/etc/spamassassin/")
     result = server.get_user_ruleset(user="******")
     self.assertEqual(result, self.mainset)