mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-08-04 20:40:14 +03:00
Update remaining get_regex_pattern usages
This commit is contained in:
parent
d1e69ad334
commit
0e9fcd19ea
|
@ -9,6 +9,7 @@ from django.db import models
|
||||||
from django.test import TestCase, override_settings
|
from django.test import TestCase, override_settings
|
||||||
|
|
||||||
from rest_framework import permissions, serializers, viewsets
|
from rest_framework import permissions, serializers, viewsets
|
||||||
|
from rest_framework.compat import get_regex_pattern
|
||||||
from rest_framework.decorators import detail_route, list_route
|
from rest_framework.decorators import detail_route, list_route
|
||||||
from rest_framework.response import Response
|
from rest_framework.response import Response
|
||||||
from rest_framework.routers import DefaultRouter, SimpleRouter
|
from rest_framework.routers import DefaultRouter, SimpleRouter
|
||||||
|
@ -176,7 +177,7 @@ class TestCustomLookupFields(TestCase):
|
||||||
|
|
||||||
def test_custom_lookup_field_route(self):
|
def test_custom_lookup_field_route(self):
|
||||||
detail_route = notes_router.urls[-1]
|
detail_route = notes_router.urls[-1]
|
||||||
detail_url_pattern = detail_route.regex.pattern
|
detail_url_pattern = get_regex_pattern(detail_route)
|
||||||
assert '<uuid>' in detail_url_pattern
|
assert '<uuid>' in detail_url_pattern
|
||||||
|
|
||||||
def test_retrieve_lookup_field_list_view(self):
|
def test_retrieve_lookup_field_list_view(self):
|
||||||
|
@ -213,7 +214,7 @@ class TestLookupValueRegex(TestCase):
|
||||||
def test_urls_limited_by_lookup_value_regex(self):
|
def test_urls_limited_by_lookup_value_regex(self):
|
||||||
expected = ['^notes/$', '^notes/(?P<uuid>[0-9a-f]{32})/$']
|
expected = ['^notes/$', '^notes/(?P<uuid>[0-9a-f]{32})/$']
|
||||||
for idx in range(len(expected)):
|
for idx in range(len(expected)):
|
||||||
assert expected[idx] == self.urls[idx].regex.pattern
|
assert expected[idx] == get_regex_pattern(self.urls[idx])
|
||||||
|
|
||||||
|
|
||||||
@override_settings(ROOT_URLCONF='tests.test_routers')
|
@override_settings(ROOT_URLCONF='tests.test_routers')
|
||||||
|
@ -228,7 +229,7 @@ class TestLookupUrlKwargs(TestCase):
|
||||||
|
|
||||||
def test_custom_lookup_url_kwarg_route(self):
|
def test_custom_lookup_url_kwarg_route(self):
|
||||||
detail_route = kwarged_notes_router.urls[-1]
|
detail_route = kwarged_notes_router.urls[-1]
|
||||||
detail_url_pattern = detail_route.regex.pattern
|
detail_url_pattern = get_regex_pattern(detail_route)
|
||||||
assert '^notes/(?P<text>' in detail_url_pattern
|
assert '^notes/(?P<text>' in detail_url_pattern
|
||||||
|
|
||||||
def test_retrieve_lookup_url_kwarg_detail_view(self):
|
def test_retrieve_lookup_url_kwarg_detail_view(self):
|
||||||
|
@ -252,7 +253,7 @@ class TestTrailingSlashIncluded(TestCase):
|
||||||
def test_urls_have_trailing_slash_by_default(self):
|
def test_urls_have_trailing_slash_by_default(self):
|
||||||
expected = ['^notes/$', '^notes/(?P<pk>[^/.]+)/$']
|
expected = ['^notes/$', '^notes/(?P<pk>[^/.]+)/$']
|
||||||
for idx in range(len(expected)):
|
for idx in range(len(expected)):
|
||||||
assert expected[idx] == self.urls[idx].regex.pattern
|
assert expected[idx] == get_regex_pattern(self.urls[idx])
|
||||||
|
|
||||||
|
|
||||||
class TestTrailingSlashRemoved(TestCase):
|
class TestTrailingSlashRemoved(TestCase):
|
||||||
|
@ -267,7 +268,7 @@ class TestTrailingSlashRemoved(TestCase):
|
||||||
def test_urls_can_have_trailing_slash_removed(self):
|
def test_urls_can_have_trailing_slash_removed(self):
|
||||||
expected = ['^notes$', '^notes/(?P<pk>[^/.]+)$']
|
expected = ['^notes$', '^notes/(?P<pk>[^/.]+)$']
|
||||||
for idx in range(len(expected)):
|
for idx in range(len(expected)):
|
||||||
assert expected[idx] == self.urls[idx].regex.pattern
|
assert expected[idx] == get_regex_pattern(self.urls[idx])
|
||||||
|
|
||||||
|
|
||||||
class TestNameableRoot(TestCase):
|
class TestNameableRoot(TestCase):
|
||||||
|
|
|
@ -9,7 +9,7 @@ from django.test import TestCase, override_settings
|
||||||
from rest_framework import (
|
from rest_framework import (
|
||||||
filters, generics, pagination, permissions, serializers
|
filters, generics, pagination, permissions, serializers
|
||||||
)
|
)
|
||||||
from rest_framework.compat import coreapi, coreschema
|
from rest_framework.compat import coreapi, coreschema, get_regex_pattern
|
||||||
from rest_framework.decorators import (
|
from rest_framework.decorators import (
|
||||||
api_view, detail_route, list_route, schema
|
api_view, detail_route, list_route, schema
|
||||||
)
|
)
|
||||||
|
@ -689,7 +689,7 @@ class SchemaGenerationExclusionTests(TestCase):
|
||||||
inspector = EndpointEnumerator(self.patterns)
|
inspector = EndpointEnumerator(self.patterns)
|
||||||
|
|
||||||
# Not pretty. Mimics internals of EndpointEnumerator to put should_include_endpoint under test
|
# Not pretty. Mimics internals of EndpointEnumerator to put should_include_endpoint under test
|
||||||
pairs = [(inspector.get_path_from_regex(pattern.regex.pattern), pattern.callback)
|
pairs = [(inspector.get_path_from_regex(get_regex_pattern(pattern)), pattern.callback)
|
||||||
for pattern in self.patterns]
|
for pattern in self.patterns]
|
||||||
|
|
||||||
should_include = [
|
should_include = [
|
||||||
|
|
Loading…
Reference in New Issue
Block a user