def test_resource_takes_precedence_over_param(self): user = factories.UserFactory(username='******') request = self._create_request( user, username_in_resource='another_user', username_in_param='this_user', ) self.assertFalse(permissions.IsUserInUrl().has_permission(request, None)) request = self._create_request( user, username_in_resource='this_user', username_in_param='another_user', ) self.assertTrue(permissions.IsUserInUrl().has_permission(request, None))
def test_user_in_url_resource(self, has_user_in_resource): user = factories.UserFactory(username='******') request = self._create_request( user, username_in_resource=user.username if has_user_in_resource else 'another_user', ) self.assertEqual(permissions.IsUserInUrl().has_permission(request, None), has_user_in_resource)