Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_impersonated_as_tag(self, real_admin, real_user, rf, in_session, expected):
obj = ImpostorLog.objects.create(impostor=real_admin, imposted_as=real_user)
setattr(rf, 'session', {})
if in_session:
rf.session['impostor_token'] = obj.token
result = get_impersonated_as(rf)
if expected:
assert result == obj
else:
assert result != obj
def test_impostor_log_str(self, real_admin, real_user):
obj = ImpostorLog.objects.create(impostor=real_admin, imposted_as=real_user)
assert str(obj) == '{} as {}'.format(real_admin.username, real_user.username)