Skip to content

Commit

Permalink
Better test coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
enzofrnt committed May 17, 2024
1 parent 3f9eeaf commit c32c86a
Showing 1 changed file with 25 additions and 6 deletions.
31 changes: 25 additions & 6 deletions test/app/hybridroutertest/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from hybridrouter import HybridRouter
from hybridroutertest.views import ServerConfigView, ClientModsView, ServerModsView, ServerConfigViewSet
from django.urls import path, include
from unittest.mock import patch

urlpatterns = []

Expand Down Expand Up @@ -97,9 +98,27 @@ def setUpTestData(cls):
def test_intermediary_view_not_present(self):
with self.assertRaises(NoReverseMatch):
reverse('mods')

# viewset_url = reverse('coucou-list')
# viewset_response = self.client.get(viewset_url)
# self.assertEqual(viewset_response.status_code, 200)
# attended_data = {'a': 'b'}
# self.assertEqual(viewset_response.data, attended_data)

class HybridRouterWithoutSpectacularWithIntermediaryViews(HybridRouterTestCaseWithIntermediaryViews):
@classmethod
@patch.dict('sys.modules', {'drf_spectacular.utils': None})
def setUpTestData(cls):
try:
import importlib
hybridrouter_module = importlib.import_module('hybridrouter')
importlib.reload(hybridrouter_module)
super().setUpTestData()
except Exception as e:
cls.fail(f"HybridRouter failed when drf_spectacular is not installed: {e}")

class HybridRouterWithoutSpectacularWithoutIntermediaryViews(HybridRouterTestCaseWithoutIntermediaryViews):
@classmethod
@patch.dict('sys.modules', {'drf_spectacular.utils': None})
def setUpTestData(cls):
try:
import importlib
hybridrouter_module = importlib.import_module('hybridrouter')
importlib.reload(hybridrouter_module)
super().setUpTestData()
except Exception as e:
cls.fail(f"HybridRouter failed when drf_spectacular is not installed: {e}")

0 comments on commit c32c86a

Please sign in to comment.