launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #05776
[Merge] lp:~mbp/launchpad/demomode-feature into lp:launchpad
Martin Pool has proposed merging lp:~mbp/launchpad/demomode-feature into lp:launchpad.
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~mbp/launchpad/demomode-feature/+merge/84049
This splits out one perhaps useful cleanup: a specific feature to test demo site behaviour. It's only used twice but otoh I already wrote it for an abandoned branch adding a third use.
--
https://code.launchpad.net/~mbp/launchpad/demomode-feature/+merge/84049
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~mbp/launchpad/demomode-feature into lp:launchpad.
=== modified file 'lib/canonical/launchpad/pagetests/basics/demo-and-lpnet.txt'
--- lib/canonical/launchpad/pagetests/basics/demo-and-lpnet.txt 2011-09-29 10:23:29 +0000
+++ lib/canonical/launchpad/pagetests/basics/demo-and-lpnet.txt 2011-12-01 02:29:28 +0000
@@ -27,15 +27,9 @@
information and styles.
# Set config to pretend we're on a demo site:
- >>> from textwrap import dedent
- >>> site_message = ('This is a demo site mmk. '
- ... '<a href="http://example.com">File a bug</a>.')
- >>> test_data = dedent("""
- ... [launchpad]
- ... is_demo: True
- ... site_message: %s
- ... """ % site_message)
- >>> config.push('test_data', test_data)
+ >>> from lp.testing.fixture import DemoMode
+ >>> demo_mode_fixture = DemoMode()
+ >>> demo_mode_fixture.setUp()
>>> print config.launchpad.is_demo
True
@@ -61,8 +55,7 @@
When you are not on a demo site, the text no longer appears.
- >>> # Restore the previous config:
- >>> config_data = config.pop('test_data')
+ >>> demo_mode_fixture.cleanUp()
>>> print config.launchpad.is_demo
False
=== modified file 'lib/lp/registry/browser/tests/test_product.py'
--- lib/lp/registry/browser/tests/test_product.py 2011-11-28 05:14:57 +0000
+++ lib/lp/registry/browser/tests/test_product.py 2011-12-01 02:29:28 +0000
@@ -27,6 +27,9 @@
person_logged_in,
TestCaseWithFactory,
)
+from lp.testing.fixture import (
+ DemoMode,
+ )
from lp.testing.mail_helpers import pop_notifications
from lp.testing.service_usage_helpers import set_service_usage
from lp.testing.views import (
@@ -164,10 +167,7 @@
self.assertTrue(message is not None)
def test_staging_message_is_demo(self):
- config.push('staging-test', '''
- [launchpad]
- is_demo: true
- ''')
+ self.useFixture(DemoMode())
view = create_initialized_view(self.product_set, '+new')
message = find_tag_by_id(view.render(), 'staging-message')
self.assertEqual(None, message)
=== modified file 'lib/lp/testing/fixture.py'
--- lib/lp/testing/fixture.py 2011-11-23 07:29:09 +0000
+++ lib/lp/testing/fixture.py 2011-12-01 02:29:28 +0000
@@ -6,6 +6,7 @@
__metaclass__ = type
__all__ = [
'CaptureOops',
+ 'DemoMode',
'PGBouncerFixture',
'Urllib2Fixture',
'ZopeAdapterFixture',
@@ -344,3 +345,21 @@
self.timeline = get_request_timeline(
get_current_browser_request())
self.addCleanup(webapp.adapter.clear_request_started)
+
+
+class DemoMode(Fixture):
+ """Run with an is_demo configuration.
+
+ This changes the page styling, feature flag permissions, and perhaps
+ other things.
+ """
+
+ def setUp(self):
+ Fixture.setUp(self)
+ config.push('demo-fixture', '''
+[launchpad]
+is_demo: true
+site_message = This is a demo site mmk. \
+<a href="http://example.com">File a bug</a>.
+ ''')
+ self.addCleanup(lambda: config.pop('demo-fixture'))