Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ and this project adheres to
### Fixed

- Fix type of `statement.result.score.scaled` from `int` to `Decimal`
- Fix misregistered `TypeError` in Pydantic models validation
- Fix `check-changelog` CI job by replacing the removed `git whatchanged`
command with `git log --name-only`
- Make MongoDB delete-failure tests tolerant to pymongo error message changes
Expand Down
2 changes: 1 addition & 1 deletion src/ralph/backends/lrs/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def validate_iso_datetime_str(value: Union[str, datetime]) -> datetime:
to an ISO 8601 date time string.
"""
if not isinstance(value, (str, datetime)):
raise TypeError("a string or datetime is required")
raise ValueError("a string or datetime is required")

if isinstance(value, datetime):
return value.isoformat()
Expand Down
4 changes: 2 additions & 2 deletions src/ralph/models/xapi/base/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def __str__(self): # noqa: D105
def validate_language_tag(cls, tag):
"""Check whether the provided tag is a valid RFC 5646 Language tag."""
if not tag_is_valid(str(tag)):
raise TypeError("Invalid RFC 5646 Language tag")
raise ValueError("Invalid RFC 5646 Language tag")
return str(tag)


Expand All @@ -54,7 +54,7 @@ class MailtoEmail(RootModel[str]):
def validate(self) -> Type["MailtoEmail"]:
"""Check whether the provided value follows the `mailto:email` format."""
if not self.root.startswith("mailto:"):
raise TypeError("Invalid `mailto:email` value")
raise ValueError("Invalid `mailto:email` value")
valid = validate_email(self.root[7:])
self.root = f"mailto:{valid[1]}"
return self
4 changes: 2 additions & 2 deletions tests/models/xapi/base/test_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ class DummyLanguageTagModel(BaseModel):

tag: LanguageTag

with pytest.raises(TypeError, match="Invalid RFC 5646 Language tag"):
with pytest.raises(ValidationError, match="Invalid RFC 5646 Language tag"):
DummyLanguageTagModel(**values)


Expand Down Expand Up @@ -116,7 +116,7 @@ class DummyLanguageMapModel(BaseModel):
ValidationError,
"map\n Input should be a valid dictionary",
),
({"map": {"en-US-en": 1}}, TypeError, "Invalid RFC 5646 Language tag"),
({"map": {"en-US-en": 1}}, ValidationError, "Invalid RFC 5646 Language tag"),
(
{"map": {"en-US": []}},
ValidationError,
Expand Down
4 changes: 2 additions & 2 deletions tests/models/xapi/base/test_statements.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,13 +186,13 @@ def test_models_xapi_base_statement_with_invalid_data_types(path, value, err):
(
"actor",
{"mbox": "example@mail.com"},
TypeError,
ValidationError,
"Invalid `mailto:email` value",
),
(
"verb__display",
{"bad language tag": "foo"},
TypeError,
ValidationError,
"Invalid RFC 5646 Language tag",
),
("object__id", ["This is not an IRI"], ValidationError, "is not a valid 'IRI'"),
Expand Down