launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #27220
[Merge] ~cjwatson/launchpad:fix-webhook-tests into launchpad:master
Colin Watson has proposed merging ~cjwatson/launchpad:fix-webhook-tests into launchpad:master.
Commit message:
Avoid implicit DNS dependency in test_automatic_retries
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/+git/launchpad/+merge/404561
This test assumes that `WebhookDeliveryJob.is_limited_effort_delivery` returns False, so make sure that that's true.
This bug previously went undetected because `ObjectFactory.getUniqueURL` generated host names that weren't reserved by RFC 2606, and so tests depended on external DNS resolution of real non-reserved domains. We now generate host names under example.com to avoid that class of problem in future.
--
Your team Launchpad code reviewers is requested to review the proposed merge of ~cjwatson/launchpad:fix-webhook-tests into launchpad:master.
diff --git a/lib/lp/services/webhooks/tests/test_job.py b/lib/lp/services/webhooks/tests/test_job.py
index 7f794e0..429f392 100644
--- a/lib/lp/services/webhooks/tests/test_job.py
+++ b/lib/lp/services/webhooks/tests/test_job.py
@@ -618,7 +618,8 @@ class TestWebhookDeliveryJob(TestCaseWithFactory):
raise Exception("Unexpected jobs.")
def test_automatic_retries(self):
- hook = self.factory.makeWebhook()
+ self.useFixture(MockPatch("psutil.net_if_addrs", return_value={}))
+ hook = self.factory.makeWebhook(delivery_url=u"http://192.168.1.1/")
job = WebhookDeliveryJob.create(hook, 'test', payload={'foo': 'bar'})
client = MockWebhookClient(response_status=503)
self.useFixture(ZopeUtilityFixture(client, IWebhookClient))
diff --git a/lib/lp/testing/factory.py b/lib/lp/testing/factory.py
index a28676c..32e18d2 100644
--- a/lib/lp/testing/factory.py
+++ b/lib/lp/testing/factory.py
@@ -505,7 +505,7 @@ class ObjectFactory(
if scheme is None:
scheme = 'http'
if host is None:
- host = "%s.domain.com" % self.getUniqueUnicode('domain')
+ host = "%s.example.com" % self.getUniqueUnicode('domain')
return '%s://%s/%s' % (scheme, host, self.getUniqueUnicode('path'))
def getUniqueDate(self):