1053 |
1053 |
assert condition.evaluate() is True
|
1054 |
1054 |
|
1055 |
1055 |
|
1056 |
|
def test_has_role_templatetag(pub, variable_test_data):
|
|
1056 |
def test_has_role_templatefilter(pub, variable_test_data):
|
1057 |
1057 |
condition = Condition({'type': 'django', 'value': 'form_user|has_role:"foobar"'})
|
1058 |
1058 |
assert condition.evaluate() is False
|
1059 |
1059 |
condition = Condition({'type': 'django', 'value': 'form_user|has_role:form_role_receiver_name'})
|
... | ... | |
1080 |
1080 |
assert condition.evaluate() is False
|
1081 |
1081 |
|
1082 |
1082 |
|
|
1083 |
def test_roles_templatefilter(pub, variable_test_data):
|
|
1084 |
condition = Condition({'type': 'django', 'value': '"foobar" in form_user|roles'})
|
|
1085 |
assert condition.evaluate() is False
|
|
1086 |
condition = Condition({'type': 'django', 'value': 'form_role_receiver_name in form_user|roles'})
|
|
1087 |
assert condition.evaluate() is False
|
|
1088 |
|
|
1089 |
role = Role.select()[0]
|
|
1090 |
user = pub.user_class.select()[0]
|
|
1091 |
user.roles = [role.id, '42'] # role.id 42 does not exist
|
|
1092 |
user.store()
|
|
1093 |
|
|
1094 |
condition = Condition({'type': 'django', 'value': '"foobar" in form_user|roles'})
|
|
1095 |
assert condition.evaluate() is True
|
|
1096 |
condition = Condition({'type': 'django', 'value': 'form_role_receiver_name in form_user|roles'})
|
|
1097 |
assert condition.evaluate() is True
|
|
1098 |
condition = Condition({'type': 'django', 'value': '"barfoo" in form_user|roles'})
|
|
1099 |
assert condition.evaluate() is False
|
|
1100 |
condition = Condition({'type': 'django', 'value': 'form_var_foo_foo in form_user|roles'})
|
|
1101 |
assert condition.evaluate() is False
|
|
1102 |
|
|
1103 |
# non-user object
|
|
1104 |
condition = Condition({'type': 'django', 'value': '"foobar" in form_var_foo_foo|roles'})
|
|
1105 |
assert condition.evaluate() is False
|
|
1106 |
condition = Condition({'type': 'django', 'value': '"foobar" in xxx|roles'})
|
|
1107 |
assert condition.evaluate() is False
|
|
1108 |
|
|
1109 |
|
1083 |
1110 |
def test_lazy_now_and_today(pub, variable_test_data):
|
1084 |
1111 |
for condition_value in (
|
1085 |
1112 |
'now > "1970-01-01"',
|