Merge ~cjwatson/launchpad:fix-shorten-test-instance-name into launchpad:master

Proposed by Colin Watson
Status: Merged
Approved by: Colin Watson
Approved revision: 79a63bc2d381949673f75296155e8b6de37fd453
Merge reported by: Otto Co-Pilot
Merged at revision: not available
Proposed branch: ~cjwatson/launchpad:fix-shorten-test-instance-name
Merge into: launchpad:master
Diff against target: 54 lines (+5/-12)
2 files modified
lib/lp/testing/tests/test_layers_functional.py (+2/-5)
lib/lp/testing/tests/test_pgsql.py (+3/-7)
Reviewer Review Type Date Requested Status
Jürgen Gmach Approve
Review via email: mp+415917@code.launchpad.net

Commit message

Fix tests to handle shorter test DB instance names

Description of the change

They no longer use UUIDs, so don't test for that.

To post a comment you must log in.
Revision history for this message
Jürgen Gmach (jugmac00) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
diff --git a/lib/lp/testing/tests/test_layers_functional.py b/lib/lp/testing/tests/test_layers_functional.py
index 1787087..212701a 100644
--- a/lib/lp/testing/tests/test_layers_functional.py
+++ b/lib/lp/testing/tests/test_layers_functional.py
@@ -10,7 +10,6 @@ to confirm that the environment hasn't been corrupted by tests
10import io10import io
11import os11import os
12import signal12import signal
13import uuid
1413
15import amqp14import amqp
16from fixtures import (15from fixtures import (
@@ -105,11 +104,9 @@ class TestBaseLayer(TestCase):
105 def test_allocates_LP_TEST_INSTANCE(self):104 def test_allocates_LP_TEST_INSTANCE(self):
106 self.useFixture(BaseLayerIsolator())105 self.useFixture(BaseLayerIsolator())
107 with LayerFixture(BaseLayer):106 with LayerFixture(BaseLayer):
108 pid, raw_uuid = os.environ['LP_TEST_INSTANCE'].split('_', 1)107 pid, suffix = os.environ['LP_TEST_INSTANCE'].split('_', 1)
109 self.assertEqual(str(os.getpid()), pid)108 self.assertEqual(str(os.getpid()), pid)
110 instance_uuid = uuid.UUID(raw_uuid)109 self.assertEqual(24, len(suffix))
111 self.assertEqual(uuid.RFC_4122, instance_uuid.variant)
112 self.assertEqual(1, instance_uuid.version)
113 self.assertEqual(None, os.environ.get('LP_TEST_INSTANCE'))110 self.assertEqual(None, os.environ.get('LP_TEST_INSTANCE'))
114111
115 def test_persist_test_services_disables_LP_TEST_INSTANCE(self):112 def test_persist_test_services_disables_LP_TEST_INSTANCE(self):
diff --git a/lib/lp/testing/tests/test_pgsql.py b/lib/lp/testing/tests/test_pgsql.py
index 48470f9..8ab14c0 100644
--- a/lib/lp/testing/tests/test_pgsql.py
+++ b/lib/lp/testing/tests/test_pgsql.py
@@ -2,7 +2,6 @@
2# GNU Affero General Public License version 3 (see the file LICENSE).2# GNU Affero General Public License version 3 (see the file LICENSE).
33
4import os4import os
5import uuid
65
7from fixtures import (6from fixtures import (
8 EnvironmentVariableFixture,7 EnvironmentVariableFixture,
@@ -37,12 +36,9 @@ class TestPgTestSetup(testtools.TestCase, TestWithFixtures):
37 BaseLayer.setUp()36 BaseLayer.setUp()
38 self.addCleanup(BaseLayer.tearDown)37 self.addCleanup(BaseLayer.tearDown)
39 fixture = PgTestSetup(dbname=PgTestSetup.dynamic)38 fixture = PgTestSetup(dbname=PgTestSetup.dynamic)
40 raw_uuid = os.environ['LP_TEST_INSTANCE'].split('_', 1)[1]39 suffix = os.environ['LP_TEST_INSTANCE'].split('_', 1)[1]
41 instance_uuid = uuid.UUID(raw_uuid)40 self.assertEqual(24, len(suffix))
42 self.assertEqual(uuid.RFC_4122, instance_uuid.variant)41 expected_name = "%s_%d_%s" % (PgTestSetup.dbname, os.getpid(), suffix)
43 self.assertEqual(1, instance_uuid.version)
44 expected_name = "%s_%d_%s" % (
45 PgTestSetup.dbname, os.getpid(), instance_uuid.hex)
46 self.assertDBName(expected_name, fixture)42 self.assertDBName(expected_name, fixture)
4743
48 def test_db_naming_without_LP_TEST_INSTANCE_is_static(self):44 def test_db_naming_without_LP_TEST_INSTANCE_is_static(self):

Subscribers

People subscribed via source and target branches

to status/vote changes: