Pārlūkot izejas kodu

Corner cases for admin_promote and admin_demote

Yentl Van Tendeloo 7 gadi atpakaļ
vecāks
revīzija
fb9a1fe9a1
2 mainītis faili ar 16 papildinājumiem un 5 dzēšanām
  1. 3 5
      bootstrap/core_algorithm.alc
  2. 13 0
      unit/test_all.py

+ 3 - 5
bootstrap/core_algorithm.alc

@@ -2230,11 +2230,9 @@ String function cmd_group_list():
 	result = "Success: "
 	groups = allAssociationDestinations(core, current_user_id, "belongsTo")
 	while (set_len(groups) > 0):
-		group_id = set_pop(groups)
-		if (set_in(allAssociationDestinations(core, group_id, "owner"), current_user_id)):
-			admin = " A "
-		else:
-			admin = "   "
+		egroup_id = set_pop(groups2
+		if (set_in(allAssociationDestinations(core, group_id, "owner"),
+		current_user_id)): admin = " A " else: admin = "   "
 
 		result = result + (string_join(admin, read_attribute(core, group_id, "name")) + "\n")
 

+ 13 - 0
unit/test_all.py

@@ -689,6 +689,19 @@ class TestModelverse(unittest.TestCase):
         admin_promote("HUTN")
         admin_demote("HUTN")
 
+        # Unknown user
+        try:
+            admin_promote("user3")
+            self.fail()
+        except UnknownUser:
+            pass
+
+        try:
+            admin_demote("user4")
+            self.fail()
+        except UnknownUser:
+            pass
+
         # Can also demote ourselves again
         admin_demote("user")