def test_mute_help_available(self):
     # There is a help link available next to the mute/unmute button.
     person = self.factory.makePerson()
     with feature_flags():
         with person_logged_in(person):
             self.bug.subscribe(person, person, level=BugNotificationLevel.METADATA)
             self.bug.mute(person, person)
             request = LaunchpadTestRequest()
             request.features = get_relevant_feature_controller()
             view = create_initialized_view(self.bug, name="+portlet-subscription", request=request)
             html = view.render()
     self.assertTrue('class="sprite maybe action-icon mute-help"' in html)
Exemplo n.º 2
0
    def _setUp(self):
        """Set the feature flags that this fixture is responsible for."""
        rule_source = self.makeRuleSource(self.makeNewRules())

        original_controller = get_relevant_feature_controller()

        def scope_lookup(scope_name):
            request = get_current_browser_request()
            return ScopesFromRequest(request).lookup(scope_name)

        if self.override_scope_lookup:
            scope_lookup = self.override_scope_lookup
        install_feature_controller(FeatureController(scope_lookup,
                                                     rule_source))
        self.addCleanup(install_feature_controller, original_controller)
 def test_mute_help_available(self):
     # There is a help link available next to the mute/unmute button.
     person = self.factory.makePerson()
     with feature_flags():
         with person_logged_in(person):
             self.bug.subscribe(person,
                                person,
                                level=BugNotificationLevel.METADATA)
             self.bug.mute(person, person)
             request = LaunchpadTestRequest()
             request.features = get_relevant_feature_controller()
             view = create_initialized_view(self.bug,
                                            name="+portlet-subscription",
                                            request=request)
             html = view.render()
     self.assertTrue('class="sprite maybe action-icon mute-help"' in html)
Exemplo n.º 4
0
    def setUp(self):
        """Set the feature flags that this fixture is responsible for."""
        super(FeatureFixture, self).setUp()

        rule_source = StormFeatureRuleSource()
        self.addCleanup(
            rule_source.setAllRules, rule_source.getAllRulesAsTuples())
        rule_source.setAllRules(self.makeNewRules())

        original_controller = get_relevant_feature_controller()

        def scope_lookup(scope_name):
            request = get_current_browser_request()
            return ScopesFromRequest(request).lookup(scope_name)

        if self.override_scope_lookup:
            scope_lookup = self.override_scope_lookup
        install_feature_controller(
            FeatureController(scope_lookup, rule_source))
        self.addCleanup(install_feature_controller, original_controller)
Exemplo n.º 5
0
    def run(self, use_web_security=False, isolation=None):
        """Actually run the script, executing zcml and initZopeless."""

        if isolation is None:
            isolation = 'read_committed'
        self._init_zca(use_web_security=use_web_security)
        self._init_db(isolation=isolation)

        # XXX wgrant 2011-09-24 bug=29744: initZopeless used to do this.
        # Should be called directly by scripts that actually need it.
        set_immediate_mail_delivery(True)

        date_started = datetime.datetime.now(UTC)
        profiler = None
        if self.options.profile:
            profiler = Profile()

        original_feature_controller = get_relevant_feature_controller()
        install_feature_controller(make_script_feature_controller(self.name))
        try:
            if profiler:
                profiler.runcall(self.main)
            else:
                self.main()
        except LaunchpadScriptFailure as e:
            self.logger.error(str(e))
            sys.exit(e.exit_status)
        except SilentLaunchpadScriptFailure as e:
            sys.exit(e.exit_status)
        else:
            date_completed = datetime.datetime.now(UTC)
            self.record_activity(date_started, date_completed)
        finally:
            install_feature_controller(original_feature_controller)
        if profiler:
            profiler.dump_stats(self.options.profile)
Exemplo n.º 6
0
    def run(self, use_web_security=False, isolation=None):
        """Actually run the script, executing zcml and initZopeless."""

        if isolation is None:
            isolation = 'read_committed'
        self._init_zca(use_web_security=use_web_security)
        self._init_db(isolation=isolation)

        # XXX wgrant 2011-09-24 bug=29744: initZopeless used to do this.
        # Should be called directly by scripts that actually need it.
        set_immediate_mail_delivery(True)

        date_started = datetime.datetime.now(UTC)
        profiler = None
        if self.options.profile:
            profiler = Profile()

        original_feature_controller = get_relevant_feature_controller()
        install_feature_controller(make_script_feature_controller(self.name))
        try:
            if profiler:
                profiler.runcall(self.main)
            else:
                self.main()
        except LaunchpadScriptFailure as e:
            self.logger.error(str(e))
            sys.exit(e.exit_status)
        except SilentLaunchpadScriptFailure as e:
            sys.exit(e.exit_status)
        else:
            date_completed = datetime.datetime.now(UTC)
            self.record_activity(date_started, date_completed)
        finally:
            install_feature_controller(original_feature_controller)
        if profiler:
            profiler.dump_stats(self.options.profile)
Exemplo n.º 7
0
 def installFeatureController(self, feature_controller):
     old_features = features.get_relevant_feature_controller()
     features.install_feature_controller(feature_controller)
     self.addCleanup(
         features.install_feature_controller, old_features)
 def test_script_restores_feature_controller(self):
     previous_controller = NullFeatureController()
     install_feature_controller(previous_controller)
     FakeScript(name="mongo").run()
     self.assertEqual(
         previous_controller, get_relevant_feature_controller())
 def setUp(self):
     super(TestScriptFeatureController, self).setUp()
     self.original_controller = get_relevant_feature_controller()
 def main(self):
     self.observed_feature_controller = get_relevant_feature_controller()
Exemplo n.º 11
0
 def installFeatureController(self, feature_controller):
     old_features = features.get_relevant_feature_controller()
     features.install_feature_controller(feature_controller)
     self.addCleanup(features.install_feature_controller, old_features)
Exemplo n.º 12
0
 def test_fixture_uses_memory(self):
     self.useFixture(self.fixture_cls({'one': '1'}))
     self.assertIsInstance(get_relevant_feature_controller().rule_source,
                           MemoryFeatureRuleSource)