From 53f18f3368665881ce566e367ed06803a6f75bb4 Mon Sep 17 00:00:00 2001 From: Ryan P Kilby Date: Mon, 4 Dec 2017 03:25:23 -0500 Subject: [PATCH] Test router setting initkwargs --- tests/test_routers.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/tests/test_routers.py b/tests/test_routers.py index 07a57fe55..5a1cfe8f4 100644 --- a/tests/test_routers.py +++ b/tests/test_routers.py @@ -7,6 +7,7 @@ from django.conf.urls import include, url from django.core.exceptions import ImproperlyConfigured from django.db import models from django.test import TestCase, override_settings +from django.urls import resolve from rest_framework import permissions, serializers, viewsets from rest_framework.compat import get_regex_pattern @@ -435,3 +436,18 @@ class TestRegexUrlPath(TestCase): response = self.client.get('/regex/{}/detail/{}/'.format(pk, kwarg)) assert response.status_code == 200 assert json.loads(response.content.decode('utf-8')) == {'pk': pk, 'kwarg': kwarg} + + +@override_settings(ROOT_URLCONF='tests.test_routers') +class TestViewInitkwargs(TestCase): + def test_suffix(self): + match = resolve('/example/notes/') + initkwargs = match.func.initkwargs + + assert initkwargs['suffix'] == 'List' + + def test_basename(self): + match = resolve('/example/notes/') + initkwargs = match.func.initkwargs + + assert initkwargs['basename'] == 'routertestmodel'