<s> import unittest <EOL> from will . mixins . roster import RosterMixin <EOL> from will import settings <EOL> from will . acl import get_acl_members , is_acl_allowed <EOL> from mock import patch <EOL> class TestIsAdmin ( unittest . TestCase ) : <EOL> def setUp ( self ) : <EOL> self . message = { '<STR_LIT>' : '<STR_LIT>' } <EOL> @ patch ( '<STR_LIT>' ) <EOL> def test_message_is_from_admin_true_if_not_set ( self , mock_get_user_from_message ) : <EOL> settings . ADMINS = '<STR_LIT:*>' <EOL> mock_get_user_from_message . return_value = self . message <EOL> self . assertTrue ( RosterMixin ( ) . message_is_from_admin ( self . message ) ) <EOL> @ patch ( '<STR_LIT>' ) <EOL> def test_message_is_from_admin_true_if_enlisted ( self , mock_get_user_from_message ) : <EOL> settings . ADMINS = [ '<STR_LIT>' ] <EOL> mock_get_user_from_message . return_value = self . message <EOL> self . assertTrue ( RosterMixin ( ) . message_is_from_admin ( self . message ) ) <EOL> @ patch ( '<STR_LIT>' ) <EOL> def test_message_is_from_admin_false_if_not_enlisted ( self , mock_get_user_from_message ) : <EOL> settings . ADMINS = [ '<STR_LIT>' ] <EOL> mock_get_user_from_message . return_value = self . message <EOL> self . assertFalse ( RosterMixin ( ) . message_is_from_admin ( self . message ) ) <EOL> @ patch ( '<STR_LIT>' ) <EOL> def test_message_is_from_admin_false_if_not_lowercase ( self , mock_get_user_from_message ) : <EOL> settings . ADMINS = [ '<STR_LIT>' ] <EOL> mock_get_user_from_message . return_value = self . message <EOL> self . assertFalse ( RosterMixin ( ) . message_is_from_admin ( self . message ) ) <EOL> class TestVerifyAcl ( unittest . TestCase ) : <EOL> def setUp ( self ) : <EOL> settings . ACL = { <EOL> "<STR_LIT>" : [ "<STR_LIT>" , "<STR_LIT>" ] , <EOL> "<STR_LIT>" : [ "<STR_LIT>" ] <EOL> } <EOL> def test_is_acl_allowed_returns_true ( self ) : <EOL> self . assertTrue ( is_acl_allowed ( "<STR_LIT>" , { "<STR_LIT>" } ) ) <EOL> self . assertTrue ( is_acl_allowed ( "<STR_LIT>" , { "<STR_LIT>" } ) ) <EOL> self . assertTrue ( is_acl_allowed ( "<STR_LIT>" , { "<STR_LIT>" } ) ) <EOL> self . assertTrue ( is_acl_allowed ( "<STR_LIT>" , { "<STR_LIT>" , "<STR_LIT>" } ) ) <EOL> self . assertTrue ( is_acl_allowed ( "<STR_LIT>" , { "<STR_LIT>" , "<STR_LIT>" } ) ) <EOL> def test_is_acl_allowed_returns_false ( self ) : <EOL> self . assertFalse ( is_acl_allowed ( "<STR_LIT>" , { "<STR_LIT>" } ) ) <EOL> self . assertFalse ( is_acl_allowed ( "<STR_LIT>" , { "<STR_LIT>" } ) ) <EOL> self . assertFalse ( is_acl_allowed ( "<STR_LIT>" , { "<STR_LIT>" } ) ) <EOL> self . assertFalse ( is_acl_allowed ( "<STR_LIT>" , { "<STR_LIT>" } ) ) </s>
