summaryrefslogtreecommitdiff
path: root/tests/base.py
diff options
context:
space:
mode:
authorJames E. Blair <jim@acmegating.com>2023-04-17 15:51:56 -0700
committerJames E. Blair <jim@acmegating.com>2023-04-17 16:51:50 -0700
commit4e0da6221409d63124b2d8ba257df03209314a3d (patch)
tree6bd7e8abe5b9af0a56f7955df651692230cba2cf /tests/base.py
parentcaa6f2ba24880cf512027e7ce2e7a19213ae7db2 (diff)
downloadzuul-4e0da6221409d63124b2d8ba257df03209314a3d.tar.gz
Further fix getting topic changes by git needs
The test helper method that handles fake gerrit queries had a bug which would cause the "topic:" queries to return all open changes. When we correct that, we can see, by virtue of a newly raised execption that there was some unexercised code in getChangesByTopic which is now exercised. This change also corrects the exception that is raised when mutating a set while iterating over it. Change-Id: I1874482b2c28fd1082fcd56036afb20333232409
Diffstat (limited to 'tests/base.py')
-rw-r--r--tests/base.py26
1 files changed, 14 insertions, 12 deletions
diff --git a/tests/base.py b/tests/base.py
index 1cfcecde5..c031497a2 100644
--- a/tests/base.py
+++ b/tests/base.py
@@ -1504,8 +1504,9 @@ class FakeGerritConnection(gerritconnection.GerritConnection):
msg = msg[1:-1]
l = [queryMethod(change) for change in self.changes.values()
if msg in change.data['commitMessage']]
- elif query.startswith("status:"):
+ else:
cut_off_time = 0
+ l = list(self.changes.values())
parts = query.split(" ")
for part in parts:
if part.startswith("-age"):
@@ -1513,17 +1514,18 @@ class FakeGerritConnection(gerritconnection.GerritConnection):
cut_off_time = (
datetime.datetime.now().timestamp() - float(age[:-1])
)
- l = [
- queryMethod(change) for change in self.changes.values()
- if change.data["lastUpdated"] >= cut_off_time
- ]
- elif query.startswith('topic:'):
- topic = query[len('topic:'):].strip()
- l = [queryMethod(change) for change in self.changes.values()
- if topic in change.data.get('topic', '')]
- else:
- # Query all open changes
- l = [queryMethod(change) for change in self.changes.values()]
+ l = [
+ change for change in l
+ if change.data["lastUpdated"] >= cut_off_time
+ ]
+ if part.startswith('topic:'):
+ topic = part[len('topic:'):].strip()
+ l = [
+ change for change in l
+ if 'topic' in change.data
+ and topic in change.data['topic']
+ ]
+ l = [queryMethod(change) for change in l]
return l
def simpleQuerySSH(self, query, event=None):