Merge lp:~nataliabidart/ubuntu-sso-client/no-more-ping into lp:ubuntu-sso-client

Proposed by Natalia Bidart
Status: Superseded
Proposed branch: lp:~nataliabidart/ubuntu-sso-client/no-more-ping
Merge into: lp:ubuntu-sso-client
Diff against target: 130 lines (+1/-113)
2 files modified
ubuntu_sso/utils/__init__.py (+1/-31)
ubuntu_sso/utils/tests/test_common.py (+0/-82)
To merge this branch: bzr merge lp:~nataliabidart/ubuntu-sso-client/no-more-ping
Reviewer Review Type Date Requested Status
dobey (community) Needs Fixing
Review via email: mp+230706@code.launchpad.net

This proposal has been superseded by a proposal from 2014-08-13.

To post a comment you must log in.
Revision history for this message
dobey (dobey) wrote :

/home/dobey/Projects/canonical/ubuntu-sso-client/no-more-ping/ubuntu_sso/utils/__init__.py:
    39: 'defer' imported but unused
    47: 'compat' imported but unused
    47: 'webclient' imported but unused

/home/dobey/Projects/canonical/ubuntu-sso-client/no-more-ping/ubuntu_sso/utils/tests/test_common.py:
    43: 'EMAIL' imported but unused
    43: 'TOKEN' imported but unused

review: Needs Fixing

Unmerged revisions

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'ubuntu_sso/utils/__init__.py'
2--- ubuntu_sso/utils/__init__.py 2013-05-08 18:38:36 +0000
3+++ ubuntu_sso/utils/__init__.py 2014-08-13 20:13:13 +0000
4@@ -166,35 +166,5 @@
5 return ssl_cert_location
6
7
8-@defer.inlineCallbacks
9 def ping_url(url, email, credentials):
10- """Ping the 'url' with the 'email' attached to it.
11-
12- Sign the request with 'credentials'. The url must not be None.
13-
14- """
15- logger.info('Pinging server using url: %r, email: %r.',
16- url, email)
17- assert isinstance(url, compat.text_type), 'Url %r must be unicode' % url
18-
19- target_url = url
20- try:
21- target_url = url.format(email=email)
22- except IndexError: # tuple index out of range
23- target_url = url.format(email) # format the first substitution
24-
25- if target_url == url:
26- logger.debug('Original url (%r) could not be formatted, '
27- 'appending email (%r).', url, email)
28- assert url.endswith('/'), 'Url %r must end with /.' % url
29- target_url = url + email
30-
31- wc = webclient.webclient_factory()
32- try:
33- logger.debug('Opening the url %r with webclient.request.', url)
34- response = yield wc.request(target_url, oauth_credentials=credentials)
35- logger.debug('Url %r opened. Response content: %r.',
36- url, response.content)
37- defer.returnValue(response)
38- finally:
39- wc.shutdown()
40+ """Unused -- it was formerly used to let U1 know about new accounts."""
41
42=== modified file 'ubuntu_sso/utils/tests/test_common.py'
43--- ubuntu_sso/utils/tests/test_common.py 2013-05-22 20:14:40 +0000
44+++ ubuntu_sso/utils/tests/test_common.py 2014-08-13 20:13:13 +0000
45@@ -239,85 +239,3 @@
46 root = RootResource()
47 super(MockWebServer, self).__init__(root)
48
49-
50-class FakedError(Exception):
51- """A mock, test, sample, and fake exception."""
52-
53-
54-class PingUrlTestCase(TestCase):
55- """Test suite for the URL pinging."""
56-
57- @defer.inlineCallbacks
58- def setUp(self):
59- yield super(PingUrlTestCase, self).setUp()
60- self.url = 'http://example.com/'
61- self.wc = FakeWebclient()
62- self.patch(utils.webclient, "webclient_factory",
63- lambda *args: self.wc)
64-
65- @defer.inlineCallbacks
66- def test_ping_url(self):
67- """The url is opened."""
68- yield utils.ping_url(url=self.url, email=EMAIL, credentials=TOKEN)
69-
70- args, _kwargs = self.wc.called[0]
71- self.assertEqual(args[0], self.url + EMAIL)
72-
73- @defer.inlineCallbacks
74- def test_ping_url_result(self):
75- """The result is returned."""
76- result = yield utils.ping_url(url=self.url, email=EMAIL,
77- credentials=TOKEN)
78- self.assertEqual(result.content, 'response')
79-
80- @defer.inlineCallbacks
81- def test_request_is_signed_with_credentials(self):
82- """The http request to url is signed with the credentials."""
83- yield utils.ping_url(url=self.url, email=EMAIL, credentials=TOKEN)
84-
85- _args, kwargs = self.wc.called[0]
86- self.assertEqual(kwargs["oauth_credentials"], TOKEN)
87-
88- @defer.inlineCallbacks
89- def test_ping_url_formatting(self):
90- """The email is added as the first formatting argument."""
91- self.url = 'http://example.com/{email}/something/else'
92- yield utils.ping_url(url=self.url, email=EMAIL, credentials=TOKEN)
93-
94- expected = self.url.format(email=EMAIL)
95- assert len(self.wc.called) > 0
96- args, _kwargs = self.wc.called[0]
97- self.assertEqual(expected, args[0])
98-
99- @defer.inlineCallbacks
100- def test_ping_url_formatting_with_query_params(self):
101- """The email is added as the first formatting argument."""
102- self.url = 'http://example.com/{email}?something=else'
103- yield utils.ping_url(url=self.url, email=EMAIL, credentials=TOKEN)
104-
105- expected = self.url.format(email=EMAIL)
106- assert len(self.wc.called) > 0
107- args, _kwargs = self.wc.called[0]
108- self.assertEqual(expected, args[0])
109-
110- @defer.inlineCallbacks
111- def test_ping_url_formatting_no_email_kwarg(self):
112- """The email is added as the first formatting argument."""
113- self.url = 'http://example.com/{0}/yadda/?something=else'
114- yield utils.ping_url(url=self.url, email=EMAIL, credentials=TOKEN)
115-
116- expected = self.url.format(EMAIL)
117- assert len(self.wc.called) > 0
118- args, _kwargs = self.wc.called[0]
119- self.assertEqual(expected, args[0])
120-
121- @defer.inlineCallbacks
122- def test_ping_url_formatting_no_format(self):
123- """The email is appended if formatting could not be accomplished."""
124- self.url = 'http://example.com/yadda/'
125- yield utils.ping_url(url=self.url, email=EMAIL, credentials=TOKEN)
126-
127- expected = self.url + EMAIL
128- assert len(self.wc.called) > 0
129- args, _kwargs = self.wc.called[0]
130- self.assertEqual(expected, args[0])

Subscribers

People subscribed via source and target branches