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