From a35c06a5863b2b006f8c346698864b123ea7a8a6 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: May 11 2020 08:45:42 +0000 Subject: Make the tests PagureFlaskApiIssuetests.test_api_assign_issue more robust It was relying on a hard-coded ACL id which is based on the order in which the ACL were loaded into the database. As new ACL are added this order may change (and do!) resulting in a weird failing test. With this change, we're directly retrieving the ACL id using the place this ACL has in the configuration file, making this much more robust. Signed-off-by: Pierre-Yves Chibon --- diff --git a/tests/test_pagure_flask_api_issue.py b/tests/test_pagure_flask_api_issue.py index 322e028..e590cd5 100644 --- a/tests/test_pagure_flask_api_issue.py +++ b/tests/test_pagure_flask_api_issue.py @@ -29,6 +29,7 @@ sys.path.insert( 0, os.path.join(os.path.dirname(os.path.abspath(__file__)), "..") ) +import pagure.config import pagure.lib.query import tests @@ -3704,7 +3705,10 @@ class PagureFlaskApiIssuetests(tests.SimplePagureTest): # Give `issue_change_status` to this token when `issue_comment` # is required - item = pagure.lib.model.TokenAcl(token_id="pingou_foo", acl_id=8) + acl_id = ( + sorted(pagure.config.config["ACLS"]).index("issue_comment") + 1 + ) + item = pagure.lib.model.TokenAcl(token_id="pingou_foo", acl_id=acl_id) self.session.add(item) self.session.commit()