← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~cjwatson/launchpad/xenial-misc-test-fixes into lp:launchpad

 

Colin Watson has proposed merging lp:~cjwatson/launchpad/xenial-misc-test-fixes into lp:launchpad.

Commit message:
Fix miscellaneous test failures with xenial.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/xenial-misc-test-fixes/+merge/314701
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~cjwatson/launchpad/xenial-misc-test-fixes into lp:launchpad.
=== modified file 'lib/lp/app/javascript/indicator/tests/test_indicator.js'
--- lib/lp/app/javascript/indicator/tests/test_indicator.js	2013-03-20 03:41:40 +0000
+++ lib/lp/app/javascript/indicator/tests/test_indicator.js	2017-01-13 13:44:22 +0000
@@ -1,4 +1,4 @@
-/* Copyright 2011 Canonical Ltd.  This software is licensed under the
+/* Copyright 2011-2017 Canonical Ltd.  This software is licensed under the
  * GNU Affero General Public License version 3 (see the file LICENSE). */
 
 YUI.add('lp.indicator.test', function (Y) {
@@ -134,9 +134,8 @@
             Assert.areNotEqual(expected_xy[1], actual_xy[1]);
             this.indicator.setBusy();
             var final_xy = this.indicator.get('boundingBox').getXY();
-            Assert.areEqual(expected_xy[0], final_xy[0]);
-            Assert.areEqual(expected_xy[1], final_xy[1]);
-
+            Assert.isTrue(Math.abs(expected_xy[0] - final_xy[0]) <= 1);
+            Assert.isTrue(Math.abs(expected_xy[1] - final_xy[1]) <= 1);
         },
 
         test_success_hides_overlay: function() {
@@ -183,8 +182,8 @@
             this.indicator.setBusy();
             this.indicator.success();
             var expected_xy = this.indicator.get('target').getXY();
-            Assert.areEqual(expected_xy[0], Y.DOM.docScrollX());
-            Assert.areEqual(expected_xy[1], Y.DOM.docScrollY());
+            Assert.isTrue(Math.abs(expected_xy[0] - Y.DOM.docScrollX()) <= 1);
+            Assert.isTrue(Math.abs(expected_xy[1] - Y.DOM.docScrollY()) <= 1);
         },
 
         test_error_hides_overlay: function () {

=== modified file 'lib/lp/services/webapp/doc/webapp-publication.txt'
--- lib/lp/services/webapp/doc/webapp-publication.txt	2016-09-21 02:50:41 +0000
+++ lib/lp/services/webapp/doc/webapp-publication.txt	2017-01-13 13:44:22 +0000
@@ -661,7 +661,7 @@
     True
 
     >>> publication.afterCall(request, None)
-    >>> request._orig_env['launchpad.publicationticks'] < 50
+    >>> request._orig_env['launchpad.publicationticks'] < 60
     True
     >>> publication.endRequest(request, None)
 

=== modified file 'lib/lp/services/webapp/tests/test_error.py'
--- lib/lp/services/webapp/tests/test_error.py	2015-12-07 08:24:41 +0000
+++ lib/lp/services/webapp/tests/test_error.py	2017-01-13 13:44:22 +0000
@@ -1,14 +1,16 @@
-# Copyright 2011-2012 Canonical Ltd.  This software is licensed under the
+# Copyright 2011-2017 Canonical Ltd.  This software is licensed under the
 # GNU Affero General Public License version 3 (see the file LICENSE).
 
 """Test error views."""
 
 
 import httplib
+import logging
 import socket
 import time
 import urllib2
 
+from fixtures import FakeLogger
 import psycopg2
 from storm.exceptions import (
     DisconnectionError,
@@ -16,6 +18,11 @@
     )
 from testtools.content import Content
 from testtools.content_type import UTF8_TEXT
+from testtools.matchers import (
+    Equals,
+    MatchesAny,
+    MatchesListwise,
+    )
 import transaction
 from zope.app.testing import ztapi
 
@@ -113,6 +120,7 @@
 
     def test_disconnectionerror_view_integration(self):
         # Test setup.
+        self.useFixture(FakeLogger('SiteError', level=logging.CRITICAL))
         self.useFixture(Urllib2Fixture())
         bouncer = PGBouncerFixture()
         # XXX gary bug=974617, bug=1011847, bug=504291 2011-07-03:
@@ -133,19 +141,29 @@
         # our view and several OOPSes from the retries.
         bouncer.stop()
 
+        class Disconnects(Equals):
+            def __init__(self, message):
+                super(Disconnects, self).__init__(
+                    ('DisconnectionError', message))
+
         with CaptureOops() as oopses:
             error = self.getHTTPError(url)
         self.assertEqual(503, error.code)
         self.assertThat(error.read(),
                         Contains(DisconnectionErrorView.reason))
-        self.assertEqual(
-            ([('DisconnectionError', 'error with no message from the libpq')]
-             * 2) +
-            ([('DisconnectionError',
-               'could not connect to server: Connection refused')]
-             * 6),
+        self.assertThat(
             [(oops['type'], oops['value'].split('\n')[0])
-             for oops in oopses.oopses])
+             for oops in oopses.oopses],
+            MatchesListwise(
+                [MatchesAny(
+                    # libpq < 9.5.
+                    Disconnects('error with no message from the libpq'),
+                    # libpq >= 9.5.
+                    Disconnects('server closed the connection unexpectedly'))]
+                * 2 +
+                [Disconnects(
+                    'could not connect to server: Connection refused')]
+                * 6))
 
         # We keep seeing the correct exception on subsequent requests.
         with CaptureOops() as oopses:
@@ -153,12 +171,13 @@
         self.assertEqual(503, error.code)
         self.assertThat(error.read(),
                         Contains(DisconnectionErrorView.reason))
-        self.assertEqual(
-            ([('DisconnectionError',
-               'could not connect to server: Connection refused')]
-             * 8),
+        self.assertThat(
             [(oops['type'], oops['value'].split('\n')[0])
-             for oops in oopses.oopses])
+             for oops in oopses.oopses],
+            MatchesListwise(
+                [Disconnects(
+                    'could not connect to server: Connection refused')]
+                * 8))
 
         # When the database is available again, requests succeed.
         bouncer.start()
@@ -182,10 +201,10 @@
         self.assertEqual(503, error.code)
         self.assertThat(error.read(),
                         Contains(DisconnectionErrorView.reason))
-        self.assertEqual(
-            [('DisconnectionError', 'database removed')],
+        self.assertThat(
             [(oops['type'], oops['value'].split('\n')[0])
-             for oops in oopses.oopses])
+             for oops in oopses.oopses],
+            MatchesListwise([Disconnects('database removed')]))
 
         # A second request doesn't log any OOPSes.
         with CaptureOops() as oopses:
@@ -209,6 +228,7 @@
 
     def test_operationalerror_view_integration(self):
         # Test setup.
+        self.useFixture(FakeLogger('SiteError', level=logging.CRITICAL))
         self.useFixture(Urllib2Fixture())
 
         class BrokenView(object):

=== modified file 'lib/lp/soyuz/doc/package-diff.txt'
--- lib/lp/soyuz/doc/package-diff.txt	2016-01-26 15:47:37 +0000
+++ lib/lp/soyuz/doc/package-diff.txt	2017-01-13 13:44:22 +0000
@@ -275,6 +275,7 @@
 The auxiliary function below will facilitate the viewing of diff results.
 
     >>> import os
+    >>> import re
     >>> import shutil
     >>> import subprocess
     >>> import tempfile
@@ -301,7 +302,9 @@
     ...     p.communicate()
     ...     diffs = [filename for filename in sorted(os.listdir('.'))
     ...              if filename != 'the.diff']
-    ...     ordered_diff_contents = [open(diff).read() for diff in diffs]
+    ...     ordered_diff_contents = [
+    ...         re.sub(r'^diff .*\n', '', open(diff).read(), flags=re.M)
+    ...         for diff in diffs]
     ...     os.chdir(local)
     ...     shutil.rmtree(jail)
     ...     return "".join(ordered_diff_contents)


Follow ups