~stefanor/launchpadlib/bug-643699

« back to all changes in this revision

Viewing changes to src/launchpadlib/tests/test_launchpad.py

  • Committer: Leonard Richardson
  • Date: 2011-02-14 19:43:04 UTC
  • mfrom: (113.1.4 fake-edge)
  • Revision ID: leonard.richardson@canonical.com-20110214194304-6ak4km6v3x8uff3j
Tags: 1.9.6
[r=jtv] Make old code that tries to access 'edge' work, but actually access production.

Show diffs side-by-side

added added

removed removed

Lines of Context:
68
68
 
69
69
    def setUp(self):
70
70
        self.aliases = sorted(
71
 
            ['production', 'qastaging', 'staging', 'dogfood', 'dev', 'test_dev'])
 
71
            ['production', 'qastaging', 'staging', 'dogfood', 'dev',
 
72
             'test_dev', 'edge'])
72
73
 
73
74
    def test_short_names(self):
74
75
        # Ensure the short service names are all supported.
75
76
        self.assertEqual(sorted(uris.service_roots.keys()), self.aliases)
76
77
        self.assertEqual(sorted(uris.web_roots.keys()), self.aliases)
77
78
 
 
79
    def test_edge_service_root_is_production(self):
 
80
        # The edge server no longer exists, so if the client wants
 
81
        # edge we give them production.
 
82
        with warnings.catch_warnings(record=True) as caught:
 
83
            warnings.simplefilter("always")
 
84
            self.assertEqual(uris.lookup_service_root('edge'),
 
85
                             uris.lookup_service_root('production'))
 
86
 
 
87
            # The lookup caused a deprecation warning.
 
88
            self.assertEqual(len(caught), 1)
 
89
            warning, = caught
 
90
            self.assertTrue(issubclass(warning.category, DeprecationWarning))
 
91
            self.assertTrue("no longer exists" in warning.message.message)
 
92
 
 
93
    def test_edge_service_root_is_production(self):
 
94
        # The edge server no longer exists, so if the client wants
 
95
        # edge we give them production.
 
96
        with warnings.catch_warnings(record=True) as caught:
 
97
            warnings.simplefilter("always")
 
98
            self.assertEqual(uris.lookup_web_root('edge'),
 
99
                             uris.lookup_web_root('production'))
 
100
 
 
101
            # The lookup caused a deprecation warning.
 
102
            self.assertEqual(len(caught), 1)
 
103
            warning, = caught
 
104
            self.assertTrue(issubclass(warning.category, DeprecationWarning))
 
105
            self.assertTrue("no longer exists" in warning.message.message)
 
106
 
78
107
    def test_lookups(self):
79
108
        """Ensure that short service names turn into long service names."""
80
109
 
81
110
        # If the service name is a known alias, lookup methods convert
82
111
        # it to a URL.
83
 
        for alias in self.aliases:
84
 
            self.assertEqual(
85
 
                uris.lookup_service_root(alias), uris.service_roots[alias])
86
 
            self.assertEqual(
87
 
                uris.lookup_web_root(alias), uris.web_roots[alias])
 
112
        with warnings.catch_warnings():
 
113
            warnings.simplefilter("ignore")
 
114
            for alias in self.aliases:
 
115
                self.assertEqual(
 
116
                    uris.lookup_service_root(alias), uris.service_roots[alias])
 
117
                self.assertEqual(
 
118
                    uris.lookup_web_root(alias), uris.web_roots[alias])
88
119
 
89
120
        # If the service name is a valid URL, lookup methods let it
90
121
        # through.