def perform_request(client, user): url = reverse("retina:api:archive-data-api-view") client, user_model = client_force_login(client, user=user) token = "" if user_model is not None and not isinstance(user_model, str): token = f"Token {Token.objects.create(user=user_model).key}" return client.get(url, HTTP_AUTHORIZATION=token)
def perform_thumbnail_request(client, image, max_dimension): image.permit_viewing_by_retina_users() kwargs = {"pk": image.id} if max_dimension != settings.RETINA_DEFAULT_THUMBNAIL_SIZE: kwargs.update({"width": max_dimension, "height": max_dimension}) url = reverse("retina:api:image-thumbnail", kwargs=kwargs) client, user_model = client_force_login(client, user="******") token = f"Token {Token.objects.create(user=user_model).key}" response = client.get(url, HTTP_AUTHORIZATION=token) return response
def test_access(self, client, user, expected_status): image = ImageFactoryWithImageFile() image.permit_viewing_by_retina_users() url = reverse("retina:api:image-thumbnail", args=[image.pk]) client, user_model = client_force_login(client, user=user) token = "" if user_model is not None and not isinstance(user_model, str): token = f"Token {Token.objects.create(user=user_model).key}" response = client.get(url, HTTP_AUTHORIZATION=token) assert response.status_code == expected_status