<s> from rules . predicates import ( always_true , always_false , always_allow , <EOL> always_deny , is_authenticated , is_superuser , <EOL> is_staff , is_active , is_group_member ) <EOL> class User ( object ) : <EOL> is_superuser = True <EOL> is_staff = True <EOL> is_active = True <EOL> _group_names_cache = set ( [ '<STR_LIT>' ] ) <EOL> groups = [ '<STR_LIT>' ] <EOL> def is_authenticated ( self ) : <EOL> return True <EOL> class SwappedUser ( object ) : <EOL> pass <EOL> def test_always_true ( ) : <EOL> assert always_true ( ) <EOL> def test_always_false ( ) : <EOL> assert not always_false ( ) <EOL> def test_always_allow ( ) : <EOL> assert always_allow ( ) <EOL> def test_always_deny ( ) : <EOL> assert not always_deny ( ) <EOL> def test_is_authenticated ( ) : <EOL> assert is_authenticated ( User ( ) ) <EOL> assert not is_authenticated ( SwappedUser ( ) ) <EOL> def test_is_superuser ( ) : <EOL> assert is_superuser ( User ( ) ) <EOL> assert not is_superuser ( SwappedUser ( ) ) <EOL> def test_is_staff ( ) : <EOL> assert is_staff ( User ( ) ) <EOL> assert not is_staff ( SwappedUser ( ) ) <EOL> def test_is_active ( ) : <EOL> assert is_active ( User ( ) ) <EOL> assert not is_active ( SwappedUser ( ) ) <EOL> def test_is_group_member ( ) : <EOL> p1 = is_group_member ( '<STR_LIT>' ) <EOL> assert p1 . name == '<STR_LIT>' <EOL> assert p1 . num_args == <NUM_LIT:1> <EOL> p2 = is_group_member ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) <EOL> assert p2 . name == '<STR_LIT>' <EOL> p = is_group_member ( '<STR_LIT>' ) <EOL> assert p ( User ( ) ) <EOL> assert not p ( SwappedUser ( ) ) <EOL> p = is_group_member ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> assert not p ( User ( ) ) <EOL> assert not p ( SwappedUser ( ) ) </s>
