1065 |
1065 |
assert condition.evaluate() is True
|
1066 |
1066 |
|
1067 |
1067 |
|
1068 |
|
def test_has_role_templatetag(pub, variable_test_data):
|
|
1068 |
def test_has_role_templatefilter(pub, variable_test_data):
|
1069 |
1069 |
condition = Condition({'type': 'django', 'value': 'form_user|has_role:"foobar"'})
|
1070 |
1070 |
assert condition.evaluate() is False
|
1071 |
1071 |
condition = Condition({'type': 'django', 'value': 'form_user|has_role:form_role_receiver_name'})
|
... | ... | |
1092 |
1092 |
assert condition.evaluate() is False
|
1093 |
1093 |
|
1094 |
1094 |
|
|
1095 |
def test_roles_templatefilter(pub, variable_test_data):
|
|
1096 |
condition = Condition({'type': 'django', 'value': '"foobar" in form_user|roles'})
|
|
1097 |
assert condition.evaluate() is False
|
|
1098 |
condition = Condition({'type': 'django', 'value': 'form_role_receiver_name in form_user|roles'})
|
|
1099 |
assert condition.evaluate() is False
|
|
1100 |
|
|
1101 |
role = Role.select()[0]
|
|
1102 |
user = pub.user_class.select()[0]
|
|
1103 |
user.roles = [role.id, '42'] # role.id 42 does not exist
|
|
1104 |
user.store()
|
|
1105 |
|
|
1106 |
condition = Condition({'type': 'django', 'value': '"foobar" in form_user|roles'})
|
|
1107 |
assert condition.evaluate() is True
|
|
1108 |
condition = Condition({'type': 'django', 'value': 'form_role_receiver_name in form_user|roles'})
|
|
1109 |
assert condition.evaluate() is True
|
|
1110 |
condition = Condition({'type': 'django', 'value': '"barfoo" in form_user|roles'})
|
|
1111 |
assert condition.evaluate() is False
|
|
1112 |
condition = Condition({'type': 'django', 'value': 'form_var_foo_foo in form_user|roles'})
|
|
1113 |
assert condition.evaluate() is False
|
|
1114 |
|
|
1115 |
# non-user object
|
|
1116 |
condition = Condition({'type': 'django', 'value': '"foobar" in form_var_foo_foo|roles'})
|
|
1117 |
assert condition.evaluate() is False
|
|
1118 |
condition = Condition({'type': 'django', 'value': '"foobar" in xxx|roles'})
|
|
1119 |
assert condition.evaluate() is False
|
|
1120 |
|
|
1121 |
|
1095 |
1122 |
def test_lazy_now_and_today(pub, variable_test_data):
|
1096 |
1123 |
for condition_value in (
|
1097 |
1124 |
'now > "1970-01-01"',
|