Skip to content
This repository has been archived by the owner on Nov 19, 2023. It is now read-only.

Commit

Permalink
Merge pull request #253 from snok/sondrelg/django-4
Browse files Browse the repository at this point in the history
Update supported Django versions
  • Loading branch information
sondrelg authored Dec 29, 2021
2 parents d5decab + 340bfd2 commit 22513d7
Show file tree
Hide file tree
Showing 6 changed files with 175 additions and 140 deletions.
22 changes: 9 additions & 13 deletions .github/workflows/testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,11 @@ jobs:
fail-fast: false
matrix:
python-version: [ "3.7", "3.8" , "3.9", "3.10" ]
django-version: [ "2.2", "3.0", "3.1", "3.2" ]
django-version: [ "3.0", "3.1", "3.2", "4.0" ]
exclude:
# Django v4 drops Python 3.6, and 3.7 support
- django-version: 4.0
python-version: 3.7
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
Expand All @@ -50,17 +54,16 @@ jobs:
id: poetry-cache
with:
path: ~/.local
key: key-1
key: key-3
- name: Install poetry
uses: snok/install-poetry@v1
with:
version: 1.2.0a2
virtualenvs-create: false
- uses: actions/cache@v2
id: cache-venv
with:
path: .venv
key: ${{ matrix.python-version }}-${{ hashFiles('**/poetry.lock') }}-1
key: ${{ matrix.python-version }}-${{ hashFiles('**/poetry.lock') }}-2
- run: |
pip install virtualenv
virtualenv .venv
Expand All @@ -72,23 +75,16 @@ jobs:
run: |
source .venv/bin/activate
pip install "Django==${{ matrix.django-version }}"
- run: |
source .venv/bin/activate
pip install coverage[toml]
- name: Install DRF 3.11 on Django 2.2
if: matrix.django-version == '2.2'
run: pip install "djangorestframework==3.11.1"
- name: Run tests
run: |
source .venv/bin/activate
poetry run pytest --cov=. --cov-report=xml
poetry run coverage report
pytest --cov=. --cov-report xml --cov-report term-missing
- name: Archive coverage
uses: actions/upload-artifact@v2
with:
name: coverage-xml
path: coverage.xml
if: matrix.python-version == '3.10' && matrix.django-version == '3.2'
if: matrix.python-version == '3.10' && matrix.django-version == '4.0'
coverage:
needs: test
runs-on: ubuntu-latest
Expand Down
7 changes: 7 additions & 0 deletions openapi_tester/schema_tester.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,12 +170,19 @@ def get_response_schema_section(self, response: Response) -> dict[str, Any]:

def handle_one_of(self, schema_section: dict, data: Any, reference: str, **kwargs: Any):
matches = 0
passed_schema_section_formats = set()
for option in schema_section["oneOf"]:
try:
self.test_schema_section(schema_section=option, data=data, reference=f"{reference}.oneOf", **kwargs)
matches += 1
passed_schema_section_formats.add(option.get("format"))
except DocumentationError:
continue
if matches == 2 and passed_schema_section_formats == {"date", "date-time"}:
# With Django v4, the datetime validator now parses normal
# date formats successfully, so a oneOf: date // datetime section
# will succeed twice where it used to succeed once.
return
if matches != 1:
raise DocumentationError(f"{VALIDATE_ONE_OF_ERROR.format(matches=matches)}\n\nReference: {reference}.oneOf")

Expand Down
Loading

0 comments on commit 22513d7

Please sign in to comment.