aurweb/test/test_exceptions.py
Kevin Morris bad57ba502
feat(exceptions): add InvariantError
This exception is to be used when a known invariant is violated.

Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-12-09 15:10:06 -08:00

106 lines
3 KiB
Python

from aurweb import exceptions
def test_aurweb_exception():
try:
raise exceptions.AurwebException("test")
except exceptions.AurwebException as exc:
assert str(exc) == "test"
def test_maintenance_exception():
try:
raise exceptions.MaintenanceException("test")
except exceptions.MaintenanceException as exc:
assert str(exc) == "test"
def test_banned_exception():
try:
raise exceptions.BannedException("test")
except exceptions.BannedException as exc:
assert str(exc) == "test"
def test_already_voted_exception():
try:
raise exceptions.AlreadyVotedException("test")
except exceptions.AlreadyVotedException as exc:
assert str(exc) == "already voted for package base: test"
def test_broken_update_hook_exception():
try:
raise exceptions.BrokenUpdateHookException("test")
except exceptions.BrokenUpdateHookException as exc:
assert str(exc) == "broken update hook: test"
def test_invalid_arguments_exception():
try:
raise exceptions.InvalidArgumentsException("test")
except exceptions.InvalidArgumentsException as exc:
assert str(exc) == "test"
def test_invalid_packagebase_exception():
try:
raise exceptions.InvalidPackageBaseException("test")
except exceptions.InvalidPackageBaseException as exc:
assert str(exc) == "package base not found: test"
def test_invalid_comment_exception():
try:
raise exceptions.InvalidCommentException("test")
except exceptions.InvalidCommentException as exc:
assert str(exc) == "comment is too short: test"
def test_invalid_reason_exception():
try:
raise exceptions.InvalidReasonException("test")
except exceptions.InvalidReasonException as exc:
assert str(exc) == "invalid reason: test"
def test_invalid_user_exception():
try:
raise exceptions.InvalidUserException("test")
except exceptions.InvalidUserException as exc:
assert str(exc) == "unknown user: test"
def test_not_voted_exception():
try:
raise exceptions.NotVotedException("test")
except exceptions.NotVotedException as exc:
assert str(exc) == "missing vote for package base: test"
def test_packagebase_exists_exception():
try:
raise exceptions.PackageBaseExistsException("test")
except exceptions.PackageBaseExistsException as exc:
assert str(exc) == "package base already exists: test"
def test_permission_denied_exception():
try:
raise exceptions.PermissionDeniedException("test")
except exceptions.PermissionDeniedException as exc:
assert str(exc) == "permission denied: test"
def test_repository_name_exception():
try:
raise exceptions.InvalidRepositoryNameException("test")
except exceptions.InvalidRepositoryNameException as exc:
assert str(exc) == "invalid repository name: test"
def test_invariant_error():
try:
raise exceptions.InvariantError("test")
except exceptions.InvariantError as exc:
assert str(exc) == "test"