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
1diff --git a/lib/lp/testing/tests/test_layers_functional.py b/lib/lp/testing/tests/test_layers_functional.py
2index 1787087..212701a 100644
3--- a/lib/lp/testing/tests/test_layers_functional.py
4+++ b/lib/lp/testing/tests/test_layers_functional.py
5@@ -10,7 +10,6 @@ to confirm that the environment hasn't been corrupted by tests
6 import io
7 import os
8 import signal
9-import uuid
10
11 import amqp
12 from fixtures import (
13@@ -105,11 +104,9 @@ class TestBaseLayer(TestCase):
14 def test_allocates_LP_TEST_INSTANCE(self):
15 self.useFixture(BaseLayerIsolator())
16 with LayerFixture(BaseLayer):
17- pid, raw_uuid = os.environ['LP_TEST_INSTANCE'].split('_', 1)
18+ pid, suffix = os.environ['LP_TEST_INSTANCE'].split('_', 1)
19 self.assertEqual(str(os.getpid()), pid)
20- instance_uuid = uuid.UUID(raw_uuid)
21- self.assertEqual(uuid.RFC_4122, instance_uuid.variant)
22- self.assertEqual(1, instance_uuid.version)
23+ self.assertEqual(24, len(suffix))
24 self.assertEqual(None, os.environ.get('LP_TEST_INSTANCE'))
25
26 def test_persist_test_services_disables_LP_TEST_INSTANCE(self):
27diff --git a/lib/lp/testing/tests/test_pgsql.py b/lib/lp/testing/tests/test_pgsql.py
28index 48470f9..8ab14c0 100644
29--- a/lib/lp/testing/tests/test_pgsql.py
30+++ b/lib/lp/testing/tests/test_pgsql.py
31@@ -2,7 +2,6 @@
32 # GNU Affero General Public License version 3 (see the file LICENSE).
33
34 import os
35-import uuid
36
37 from fixtures import (
38 EnvironmentVariableFixture,
39@@ -37,12 +36,9 @@ class TestPgTestSetup(testtools.TestCase, TestWithFixtures):
40 BaseLayer.setUp()
41 self.addCleanup(BaseLayer.tearDown)
42 fixture = PgTestSetup(dbname=PgTestSetup.dynamic)
43- raw_uuid = os.environ['LP_TEST_INSTANCE'].split('_', 1)[1]
44- instance_uuid = uuid.UUID(raw_uuid)
45- self.assertEqual(uuid.RFC_4122, instance_uuid.variant)
46- self.assertEqual(1, instance_uuid.version)
47- expected_name = "%s_%d_%s" % (
48- PgTestSetup.dbname, os.getpid(), instance_uuid.hex)
49+ suffix = os.environ['LP_TEST_INSTANCE'].split('_', 1)[1]
50+ self.assertEqual(24, len(suffix))
51+ expected_name = "%s_%d_%s" % (PgTestSetup.dbname, os.getpid(), suffix)
52 self.assertDBName(expected_name, fixture)
53
54 def test_db_naming_without_LP_TEST_INSTANCE_is_static(self):

Subscribers

People subscribed via source and target branches

to status/vote changes: