def testDefaultToUserAgentSeries(self):
        # The distroseries version found in the user-agent header will
        # be selected by default.

        # Ubuntu version 10.09 in the user-agent should display as getsy
        view = SourcesListEntriesView(
            self.entries,
            LaunchpadTestRequest(HTTP_USER_AGENT='Mozilla/5.0 '
                                 '(X11; U; Linux i686; en-US; rv:1.9.0.10) '
                                 'Gecko/2009042523 Ubuntu/10.09 (whatever) '
                                 'Firefox/3.0.10'))
        view.initialize()

        self.assertEqual(u'getsy', view.default_series_name)

        # Ubuntu version 9.04 in the user-agent should display as feasty
        view = SourcesListEntriesView(
            self.entries,
            LaunchpadTestRequest(HTTP_USER_AGENT='Mozilla/5.0 '
                                 '(X11; U; Linux i686; en-US; rv:1.9.0.10) '
                                 'Gecko/2009042523 Ubuntu/9.04 (whatever) '
                                 'Firefox/3.0.10'))
        view.initialize()

        self.assertEqual(u'feasty', view.default_series_name)
    def testDefaultWithoutUserAgent(self):
        # If there is no user-agent setting, then we force the user
        # to make a selection.
        view = SourcesListEntriesView(self.entries, LaunchpadTestRequest())
        view.initialize()

        self.assertEqual('YOUR_IBUNTU_VERSION_HERE', view.default_series_name)
示例#3
0
 def initialize(self):
     """Set up the sources.list entries for display."""
     valid_series = []
     # use an explicit loop to preserve ordering while getting rid of dupes
     for arch_series in self.summarized_arch_series:
         series = arch_series.distro_arch_series.distroseries
         if series not in valid_series:
             valid_series.append(series)
     entries = SourcesListEntries(self.context.distribution,
                                  self.context.base_url, valid_series)
     self.sources_list_entries = SourcesListEntriesView(
         entries, self.request, initially_without_selection=True)
    def testNonRecognisedDistro(self):
        # If the supplied series in the user-agent is not recognized as a
        # valid distroseries for the distro, then we force the user to
        # make a selection.
        view = SourcesListEntriesView(
            self.entries,
            LaunchpadTestRequest(HTTP_USER_AGENT='Mozilla/5.0 '
                                 '(X11; U; Linux i686; en-US; rv:1.9.0.10) '
                                 'Gecko/2009042523 Ubunti/9.04 (whatever) '
                                 'Firefox/3.0.10'))

        view.initialize()

        self.assertEqual('YOUR_IBUNTU_VERSION_HERE', view.default_series_name)
    def setUp(self):
        TestCaseWithFactory.setUp(self)
        self.distribution = self.factory.makeDistribution(name='ibuntu')

        # Ensure there is only one series available.
        self.series = [
            self.factory.makeDistroSeries(name="feasty", version='9.04'),
        ]
        self.entries = SourcesListEntries(self.distribution,
                                          'http://example.com/my/archive',
                                          self.series)

        self.view = SourcesListEntriesView(self.entries,
                                           LaunchpadTestRequest())
        self.view.initialize()
    def testCommentDisplayedWhenProvided(self):
        # A comment provided to the constructor should appear when
        # rendered.
        my_comment = ("this comment should be displayed with the sources."
                      "list entries.")

        view = SourcesListEntriesView(self.entries,
                                      LaunchpadTestRequest(),
                                      comment=my_comment)
        view.initialize()

        html = view.__call__()
        self.assertTrue(
            '#' + my_comment in html,
            "The comment was not included in the sources.list snippet.")