From 4e0da6221409d63124b2d8ba257df03209314a3d Mon Sep 17 00:00:00 2001 From: "James E. Blair" Date: Mon, 17 Apr 2023 15:51:56 -0700 Subject: 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 --- tests/unit/test_gerrit.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'tests/unit/test_gerrit.py') diff --git a/tests/unit/test_gerrit.py b/tests/unit/test_gerrit.py index ac3dccf3b..4085e8b1b 100644 --- a/tests/unit/test_gerrit.py +++ b/tests/unit/test_gerrit.py @@ -827,6 +827,14 @@ class TestGerritFake(ZuulTestCase): config_file = "zuul-gerrit-github.conf" tenant_config_file = "config/circular-dependencies/main.yaml" + def _make_tuple(self, data): + ret = [] + for c in data: + dep_change = c['number'] + dep_ps = c['currentPatchSet']['number'] + ret.append((int(dep_change), int(dep_ps))) + return sorted(ret) + def _get_tuple(self, change_number): ret = [] data = self.fake_gerrit.get( @@ -903,6 +911,11 @@ class TestGerritFake(ZuulTestCase): ret = self.fake_gerrit._getSubmittedTogether(C1, None) self.assertEqual(ret, [(4, 1)]) + # Test also the query used by the GerritConnection: + ret = self.fake_gerrit._simpleQuery('status:open topic:test-topic') + ret = self._make_tuple(ret) + self.assertEqual(ret, [(3, 1), (4, 1)]) + class TestGerritConnection(ZuulTestCase): config_file = 'zuul-gerrit-web.conf' -- cgit v1.2.1