Skip to content

Commit

Permalink
Use settings pytest fixture
Browse files Browse the repository at this point in the history
  • Loading branch information
banesullivan committed Nov 23, 2021
1 parent 9a9f1dd commit 417c920
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 9 deletions.
6 changes: 1 addition & 5 deletions django-rgd-imagery/tests/test_rest.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import time

from django.conf import settings
import pytest
import requests
from rest_framework import status
Expand Down Expand Up @@ -94,13 +93,12 @@ def test_create_and_download_cog(admin_api_client, geotiff_image_entry):


@pytest.mark.django_db(transaction=True)
def test_tiles_endpoint_with_signature(admin_api_client, live_server):
def test_tiles_endpoint_with_signature(admin_api_client, live_server, settings):
image = factories.ImageFactory(
file__file__filename='paris_france_10.tiff',
file__file__from_path=datastore.fetch('paris_france_10.tiff'),
)
# Set the TTL to something short
prior = getattr(settings, 'RGD_SIGNED_URL_TTL', None)
settings.RGD_SIGNED_URL_TTL = 3 # seconds
# Generate a signature
response = admin_api_client.post('/api/signature')
Expand All @@ -119,5 +117,3 @@ def test_tiles_endpoint_with_signature(admin_api_client, live_server):
with pytest.raises(requests.HTTPError):
response.raise_for_status()
assert response.status_code == 401
# Reset the TTL now that test is over
settings.RGD_SIGNED_URL_TTL = prior
7 changes: 3 additions & 4 deletions django-rgd/tests/test_permissions.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from django.apps import apps
from django.conf import settings
import pytest
from rest_framework.authtoken.views import ObtainAuthToken
from rgd import models
Expand All @@ -11,9 +10,10 @@


@pytest.mark.django_db(transaction=True)
def test_unassigned_permissions_complex(user_factory, user, spatial_asset_a, spatial_asset_b):
def test_unassigned_permissions_complex(
user_factory, user, spatial_asset_a, spatial_asset_b, settings
):
# TODO: reimplement with multi raster file fixture also
prior = getattr(settings, 'RGD_GLOBAL_READ_ACCESS', None)
settings.RGD_GLOBAL_READ_ACCESS = False
admin = user_factory(is_superuser=True)
admin_q = filter_read_perm(admin, models.SpatialEntry.objects.all())
Expand All @@ -25,7 +25,6 @@ def test_unassigned_permissions_complex(user_factory, user, spatial_asset_a, spa
basic_q = filter_read_perm(user, models.SpatialEntry.objects.all())
assert len(admin_q) == len(basic_q)
assert set(admin_q) == set(basic_q)
settings.RGD_GLOBAL_READ_ACCESS = prior


@pytest.mark.django_db(transaction=True)
Expand Down

0 comments on commit 417c920

Please sign in to comment.