Skip to content

Commit

Permalink
test_rest_auth: Add test schema transforms
Browse files Browse the repository at this point in the history
  • Loading branch information
jayvdb committed Jul 20, 2020
1 parent ccf6ca2 commit 5970984
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions tests/contrib/test_rest_auth.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,18 @@
import re

import pytest
from django.urls import include, path

from drf_spectacular.generators import SchemaGenerator
from tests import assert_schema

transforms = [
# User model first_name differences
lambda x: re.sub(r'(first_name:\n *type: string\n *maxLength:) 150', r'\g<1> 30', x, re.M),
# User model username validator tail
lambda x: x.replace(r'+$', r'+\Z'),
]


@pytest.mark.contrib('rest_auth')
def test_rest_auth(no_warnings):
Expand All @@ -14,7 +23,8 @@ def test_rest_auth(no_warnings):
generator = SchemaGenerator(patterns=urlpatterns)
schema = generator.get_schema(request=None, public=True)

assert_schema(schema, 'tests/contrib/test_rest_auth.yml')
assert_schema(schema, 'tests/contrib/test_rest_auth.yml',
transforms=transforms)


@pytest.mark.contrib('rest_auth')
Expand All @@ -26,4 +36,5 @@ def test_rest_auth_registration(no_warnings):
generator = SchemaGenerator(patterns=urlpatterns)
schema = generator.get_schema(request=None, public=True)

assert_schema(schema, 'tests/contrib/test_rest_auth_registration.yml')
assert_schema(schema, 'tests/contrib/test_rest_auth_registration.yml',
transforms=transforms)

0 comments on commit 5970984

Please sign in to comment.