Skip to content

Commit

Permalink
fixup! 🏗️(project) migrate to pydantic v2 and switch tests to `poly…
Browse files Browse the repository at this point in the history
…factory`
  • Loading branch information
wilbrdt committed Apr 12, 2024
1 parent 16c97de commit c10b8c3
Show file tree
Hide file tree
Showing 10 changed files with 8 additions and 17 deletions.
2 changes: 1 addition & 1 deletion src/ralph/api/routers/statements.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ async def get( # noqa: PLR0912,PLR0913
None,
description="Filter, only return Statements matching the specified Verb id",
),
activity: Optional[Annotated[IRI, Body()]] = Query(
activity: Optional[str] = Query(
None,
description=(
"Filter, only return Statements for which the Object "
Expand Down
4 changes: 2 additions & 2 deletions src/ralph/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import io
from enum import Enum
from pathlib import Path
from typing import List, Literal, Optional, Tuple, Union
from typing import List, Optional, Tuple, Union

from pydantic import (
AfterValidator,
Expand Down Expand Up @@ -132,7 +132,7 @@ class AuthBackend(str, Enum):


def validate_auth_backends(
value: Union[AuthBackend, Tuple[AuthBackend], List[AuthBackend]]
value: Union[str, Tuple[str, ...], List[str]]
) -> Tuple[AuthBackend]:
"""Check whether the value is a comma separated string or a list/tuple."""
if isinstance(value, (tuple, list)):
Expand Down
2 changes: 1 addition & 1 deletion src/ralph/models/edx/bookmark/fields/events.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

import sys
from typing import Optional
from typing_extensions import Annotated

from pydantic import StringConstraints
from typing_extensions import Annotated

from ...base import AbstractBaseEventField

Expand Down
2 changes: 1 addition & 1 deletion src/ralph/models/edx/certificate/fields/events.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
"""Cohort event field definition."""

import sys
from typing_extensions import Annotated
from uuid import UUID

from pydantic import AnyHttpUrl, StringConstraints
from typing_extensions import Annotated

from ...base import AbstractBaseEventField

Expand Down
2 changes: 1 addition & 1 deletion src/ralph/models/edx/notes/fields/events.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

import sys
from typing import Dict, List
from typing_extensions import Annotated

from pydantic import StringConstraints
from typing_extensions import Annotated

from ...base import AbstractBaseEventField

Expand Down
2 changes: 1 addition & 1 deletion src/ralph/models/edx/teams_related/fields/events.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

import sys
from typing import List, Union
from typing_extensions import Annotated

from pydantic import StringConstraints, validator
from typing_extensions import Annotated

from ...base import AbstractBaseEventField

Expand Down
1 change: 0 additions & 1 deletion tests/backends/data/test_async_lrs.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ def test_backends_data_async_lrs_default_instantiation(monkeypatch, fs, lrs_back
assert backend.query_class == LRSStatementsQuery
assert backend.base_url == parse_obj_as(AnyHttpUrl, "http://0.0.0.0:8100")
assert backend.auth == ("ralph", "secret")
print(f"{backend.settings.HEADERS =}")
assert backend.settings.HEADERS == LRSHeaders()
assert backend.settings.LOCALE_ENCODING == "utf8"
assert backend.settings.READ_CHUNK_SIZE == 500
Expand Down
1 change: 0 additions & 1 deletion tests/backends/data/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import asyncio
import logging
import re
from typing import Any, Dict, Generic, TypeVar, Union

import pytest
Expand Down
7 changes: 0 additions & 7 deletions tests/models/edx/notes/test_events.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
"""Tests for notes models event fields."""

import json
import sys
from typing import List

import pytest
from pydantic.error_wrappers import ValidationError
Expand All @@ -15,11 +13,6 @@

from tests.factories import mock_instance

if sys.version_info >= (3, 8):
from typing import Literal
else:
from typing_extensions import Literal


def test_models_edx_notes_event_field_with_valid_field():
"""Test that a valid `NotesEventField` does not raise a
Expand Down
2 changes: 1 addition & 1 deletion tests/models/edx/notes/test_statements.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def test_models_edx_ui_edx_course_student_notes_searched_with_valid_statement():
assert statement.name == "edx.course.student_notes.searched"


def test_models_edx_ui_edx_course_student_notes_notes_page_viewed_with_valid_statement():
def test_models_edx_ui_edx_course_student_notes_notes_page_viewed_with_valid_statement(): # noqa: E501
"""Test that a `edx.course.student_notes.notes_page_viewed` statement has
the expected `event_type` and `name`.
"""
Expand Down

0 comments on commit c10b8c3

Please sign in to comment.