Skip to content

Commit

Permalink
Overriding Django SSL Redirect for Unit Tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sammy-sandhu committed Oct 22, 2024
1 parent d612dca commit b5a2c78
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 0 deletions.
6 changes: 6 additions & 0 deletions app/configurations/tests/test_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,19 @@
from rest_framework.test import APITestCase
from users.models import XDSUser

from django.test import override_settings


class TestSetUp(APITestCase):
"""Class with setup and teardown for tests in XDS"""

def setUp(self):
"""Function to set up necessary data for testing"""

settings_manager = override_settings(SECURE_SSL_REDIRECT=False)
settings_manager.enable()
self.addCleanup(settings_manager.disable)

# self.patcher = patch('users.models.email_verification')
# self.mock_email_verification = self.patcher.start()

Expand Down
6 changes: 6 additions & 0 deletions app/core/tests/test_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,19 @@
from openlxp_notifications.models import email
from rest_framework.test import APITestCase

from django.test import override_settings


class TestSetUp(APITestCase):
"""Class with setup and teardown for tests in XDS"""

def setUp(self):
"""Function to set up necessary data for testing"""

settings_manager = override_settings(SECURE_SSL_REDIRECT=False)
settings_manager.enable()
self.addCleanup(settings_manager.disable)

self.patcher = patch('core.signals.trigger_update')
self.mock_send_email = self.patcher.start()

Expand Down
13 changes: 13 additions & 0 deletions app/es_api/tests/test_views_unit.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,17 @@
from rest_framework import status
from rest_framework.test import APITestCase

from django.test import override_settings


@tag('unit')
class ViewTests(APITestCase):

def setUp(self):
settings_manager = override_settings(SECURE_SSL_REDIRECT=False)
settings_manager.enable()
self.addCleanup(settings_manager.disable)

def test_search_index_no_keyword(self):
"""
Test that the /es-api/ endpoint sends an HTTP error when no
Expand Down Expand Up @@ -156,6 +163,12 @@ def test_suggestions_missing(self):

@tag('unit')
class SearchDerivedTests(APITestCase):

def setUp(self):
settings_manager = override_settings(SECURE_SSL_REDIRECT=False)
settings_manager.enable()
self.addCleanup(settings_manager.disable)

def test_search_derived_no_reference(self):
"""
Test that the /es-api/ endpoint sends an HTTP error when no
Expand Down
6 changes: 6 additions & 0 deletions app/users/tests/test_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,19 @@
from rest_framework.test import APITestCase
from users.models import XDSUser

from django.test import override_settings


class TestSetUp(APITestCase):
"""Class with setup and teardown for tests in XDS"""

def setUp(self):
"""Function to set up necessary data for testing"""

settings_manager = override_settings(SECURE_SSL_REDIRECT=False)
settings_manager.enable()
self.addCleanup(settings_manager.disable)

# self.patcher = patch('users.models.email_verification')
# self.mock_email_verification = self.patcher.start()

Expand Down
5 changes: 5 additions & 0 deletions app/xds_api/tests/test_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,18 @@
from rest_framework.test import APITestCase
from users.models import XDSUser

from django.test import override_settings

class TestSetUp(APITestCase):
"""Class with setup and teardown for tests in XDS"""

def setUp(self):
"""Function to set up necessary data for testing"""

settings_manager = override_settings(SECURE_SSL_REDIRECT=False)
settings_manager.enable()
self.addCleanup(settings_manager.disable)

# self.patcher = patch('users.models.email_verification')
# self.mock_email_verification = self.patcher.start()

Expand Down

0 comments on commit b5a2c78

Please sign in to comment.