Skip to content

Commit

Permalink
Merge branch 'fbest/relax-tests' into 'master'
Browse files Browse the repository at this point in the history
test: relax testing of error messages

See merge request univention/components/python-udm-rest-api-client!12
  • Loading branch information
spaceone committed Dec 16, 2022
2 parents 8bb7550 + 50d4ed8 commit 90bbc61
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions tests/test_base_http.py
Original file line number Diff line number Diff line change
Expand Up @@ -702,12 +702,16 @@ async def test_saving_obj_with_bad_property_value(faker, user_created_via_http,
(
"password",
"pass",
'1 error(s) occurred:Request argument "password" Password policy error: The password is too short, at least 8 characters needed!',
re.compile(
r'.*"password" Password policy error.\s\+The password is too short, at least 8 characters needed!'
),
),
(
"birthday",
"pass",
'1 error(s) occurred:Request argument "birthday" The property birthday has an invalid value: Date does not match format "%Y-%m-%d".',
re.compile(
'.*"birthday" The property birthday has an invalid value: Date does not match format "%Y-%m-%d".'
),
),
],
)
Expand All @@ -722,7 +726,7 @@ async def test_modify_error_exception(user_created_via_http, udm_kwargs, error):
with pytest.raises(ModifyError) as exc_info:
await obj.save()
exc = exc_info.value
assert str(exc) == msg
assert msg.search(str(exc))
assert exc.reason == "Unprocessable Entity"
assert isinstance(exc.dn, str)
assert isinstance(exc.error, dict)
Expand All @@ -736,12 +740,16 @@ async def test_modify_error_exception(user_created_via_http, udm_kwargs, error):
(
"e-mail",
"pass",
'1 error(s) occurred:Request argument "e-mail" The property e-mail has an invalid value: Value must be of type array not str.',
re.compile(
'.*"e-mail" The property e-mail has an invalid value: Value must be of type array not str.'
),
),
(
"username",
None,
'1 error(s) occurred:Request argument "dn" Information provided is not sufficient. The following properties are missing:username',
re.compile(
r'.*"dn" Information provided is not sufficient. The following properties are missing:\s*username'
),
),
],
)
Expand All @@ -759,7 +767,7 @@ async def test_create_error_exception(udm_kwargs, error, faker):
with pytest.raises(CreateError) as exc_info:
await obj.save()
exc = exc_info.value
assert str(exc) == msg
assert msg.search(str(exc))
assert exc.reason == "Unprocessable Entity"
assert exc.dn is None
assert isinstance(exc.error, dict)
Expand Down

0 comments on commit 90bbc61

Please sign in to comment.