summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin Morris <kevr@0cost.org>2020-12-27 03:26:32 +0100
committerLukas Fleischer <lfleischer@archlinux.org>2021-02-20 17:52:51 +0100
commit3b7ebc7693933a2520c50fa89296a77dad020f47 (patch)
tree05dea4079fc12c69ddd71ae70dc752edd762d735
parentcc0784391b5ec3f56ef51f7cb1c5c6285d673287 (diff)
downloadaur-3b7ebc7693933a2520c50fa89296a77dad020f47.tar.gz
aur-3b7ebc7693933a2520c50fa89296a77dad020f47.tar.xz
add test_exceptions.py
This helps gain coverage over aurweb.exceptions regardless of their actual use in the testing base. Signed-off-by: Kevin Morris <kevr@0cost.org>
-rw-r--r--test/test_exceptions.py102
1 files changed, 102 insertions, 0 deletions
diff --git a/test/test_exceptions.py b/test/test_exceptions.py
new file mode 100644
index 00000000..feac2656
--- /dev/null
+++ b/test/test_exceptions.py
@@ -0,0 +1,102 @@
+from aurweb.exceptions import (AlreadyVotedException, AurwebException, BannedException, BrokenUpdateHookException,
+ InvalidArgumentsException, InvalidCommentException, InvalidPackageBaseException,
+ InvalidReasonException, InvalidRepositoryNameException, InvalidUserException,
+ MaintenanceException, NotVotedException, PackageBaseExistsException, PermissionDeniedException)
+
+
+def test_aurweb_exception():
+ try:
+ raise AurwebException("test")
+ except AurwebException as exc:
+ assert str(exc) == "test"
+
+
+def test_maintenance_exception():
+ try:
+ raise MaintenanceException("test")
+ except MaintenanceException as exc:
+ assert str(exc) == "test"
+
+
+def test_banned_exception():
+ try:
+ raise BannedException("test")
+ except BannedException as exc:
+ assert str(exc) == "test"
+
+
+def test_already_voted_exception():
+ try:
+ raise AlreadyVotedException("test")
+ except AlreadyVotedException as exc:
+ assert str(exc) == "already voted for package base: test"
+
+
+def test_broken_update_hook_exception():
+ try:
+ raise BrokenUpdateHookException("test")
+ except BrokenUpdateHookException as exc:
+ assert str(exc) == "broken update hook: test"
+
+
+def test_invalid_arguments_exception():
+ try:
+ raise InvalidArgumentsException("test")
+ except InvalidArgumentsException as exc:
+ assert str(exc) == "test"
+
+
+def test_invalid_packagebase_exception():
+ try:
+ raise InvalidPackageBaseException("test")
+ except InvalidPackageBaseException as exc:
+ assert str(exc) == "package base not found: test"
+
+
+def test_invalid_comment_exception():
+ try:
+ raise InvalidCommentException("test")
+ except InvalidCommentException as exc:
+ assert str(exc) == "comment is too short: test"
+
+
+def test_invalid_reason_exception():
+ try:
+ raise InvalidReasonException("test")
+ except InvalidReasonException as exc:
+ assert str(exc) == "invalid reason: test"
+
+
+def test_invalid_user_exception():
+ try:
+ raise InvalidUserException("test")
+ except InvalidUserException as exc:
+ assert str(exc) == "unknown user: test"
+
+
+def test_not_voted_exception():
+ try:
+ raise NotVotedException("test")
+ except NotVotedException as exc:
+ assert str(exc) == "missing vote for package base: test"
+
+
+def test_packagebase_exists_exception():
+ try:
+ raise PackageBaseExistsException("test")
+ except PackageBaseExistsException as exc:
+ assert str(exc) == "package base already exists: test"
+
+
+def test_permission_denied_exception():
+ try:
+ raise PermissionDeniedException("test")
+ except PermissionDeniedException as exc:
+ assert str(exc) == "permission denied: test"
+
+
+def test_repository_name_exception():
+ try:
+ raise InvalidRepositoryNameException("test")
+ except InvalidRepositoryNameException as exc:
+ assert str(exc) == "invalid repository name: test"