network_inventory/core/tests/helper.py
Andreas Zweili 67fa2792d9 extend the helper functions with the escape function
When the object_to_find string contained a special character which the django
template system escapes then the test filed because the helpers where looking
for the unescaped string. Now they escape the string as well.
2020-01-12 14:23:10 +01:00

16 lines
425 B
Python

from django.utils.html import escape
def in_content(response, object_to_find):
decoded_content = response.content.decode('utf8')
if str(escape(object_to_find)) not in decoded_content:
return False
return True
def not_in_content(response, object_to_find):
decoded_content = response.content.decode('utf8')
if str(escape(object_to_find)) in decoded_content:
return False
return True