← Back to team overview

launchpad-reviewers team mailing list archive

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

 

Colin Watson has proposed merging ~cjwatson/launchpad:fix-shorten-test-instance-name into launchpad:master.

Commit message:
Fix tests to handle shorter test DB instance names

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/+git/launchpad/+merge/415917

They no longer use UUIDs, so don't test for that.
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of ~cjwatson/launchpad:fix-shorten-test-instance-name into launchpad:master.
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
 import io
 import os
 import signal
-import uuid
 
 import amqp
 from fixtures import (
@@ -105,11 +104,9 @@ class TestBaseLayer(TestCase):
     def test_allocates_LP_TEST_INSTANCE(self):
         self.useFixture(BaseLayerIsolator())
         with LayerFixture(BaseLayer):
-            pid, raw_uuid = os.environ['LP_TEST_INSTANCE'].split('_', 1)
+            pid, suffix = os.environ['LP_TEST_INSTANCE'].split('_', 1)
             self.assertEqual(str(os.getpid()), pid)
-            instance_uuid = uuid.UUID(raw_uuid)
-            self.assertEqual(uuid.RFC_4122, instance_uuid.variant)
-            self.assertEqual(1, instance_uuid.version)
+            self.assertEqual(24, len(suffix))
         self.assertEqual(None, os.environ.get('LP_TEST_INSTANCE'))
 
     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 @@
 # GNU Affero General Public License version 3 (see the file LICENSE).
 
 import os
-import uuid
 
 from fixtures import (
     EnvironmentVariableFixture,
@@ -37,12 +36,9 @@ class TestPgTestSetup(testtools.TestCase, TestWithFixtures):
         BaseLayer.setUp()
         self.addCleanup(BaseLayer.tearDown)
         fixture = PgTestSetup(dbname=PgTestSetup.dynamic)
-        raw_uuid = os.environ['LP_TEST_INSTANCE'].split('_', 1)[1]
-        instance_uuid = uuid.UUID(raw_uuid)
-        self.assertEqual(uuid.RFC_4122, instance_uuid.variant)
-        self.assertEqual(1, instance_uuid.version)
-        expected_name = "%s_%d_%s" % (
-            PgTestSetup.dbname, os.getpid(), instance_uuid.hex)
+        suffix = os.environ['LP_TEST_INSTANCE'].split('_', 1)[1]
+        self.assertEqual(24, len(suffix))
+        expected_name = "%s_%d_%s" % (PgTestSetup.dbname, os.getpid(), suffix)
         self.assertDBName(expected_name, fixture)
 
     def test_db_naming_without_LP_TEST_INSTANCE_is_static(self):