Merge lp:~mandel/ubuntu-sso-client/fix-tcp-activation into lp:ubuntu-sso-client

Proposed by Manuel de la Peña on 2012-06-08
Status: Merged
Approved by: dobey on 2012-06-19
Approved revision: 968
Merged at revision: 972
Proposed branch: lp:~mandel/ubuntu-sso-client/fix-tcp-activation
Merge into: lp:ubuntu-sso-client
Diff against target: 149 lines (+44/-46)
2 files modified
ubuntu_sso/utils/tcpactivation.py (+2/-0)
ubuntu_sso/utils/tests/test_tcpactivation.py (+42/-46)
To merge this branch: bzr merge lp:~mandel/ubuntu-sso-client/fix-tcp-activation
Reviewer Review Type Date Requested Status
Roberto Alsina (community) Approve on 2012-06-15
dobey (community) 2012-06-08 Approve on 2012-06-08
Review via email: mp+109367@code.launchpad.net

Commit Message

- Changed tests so that they use u1-dev-tools better and do not get blocked in the clean up (LP: 1009071).

Description of the Change

- Changed tests so that they use u1-dev-tools better and do not get blocked in the clean up (LP: 1009071).

Please ensure that you do run the tests using lp:~mandel/ubuntuone-dev-tools/darwin-cleanup

To post a comment you must log in.
dobey (dobey) :
review: Approve
Roberto Alsina (ralsina) :
review: Approve
Ubuntu One Auto Pilot (otto-pilot) wrote :
Download full text (174.4 KiB)

The attempt to merge lp:~mandel/ubuntu-sso-client/fix-tcp-activation into lp:ubuntu-sso-client failed. Below is the output from the failed tests.

*** Running GTK test suite for ubuntu_sso ***
Starting squid version...
Waiting for squid to start....
ubuntu_sso.main.tests.test_common
  BaseTestCase
    runTest ... [OK]
  CredentialsManagementClearTestCase
    test_backend_called ... [OK]
    test_does_not_block ... [OK]
    test_handles_error ... [OK]
  CredentialsManagementFindTestCase
    test_backend_called ... [OK]
    test_does_not_block ... [OK]
    test_find_credentials_with_error_cb ... [OK]
    test_find_credentials_with_success_cb ... [OK]
    test_handles_error ... [OK]
  CredentialsManagementNotFindTestCase
    test_backend_called ... [OK]
    test_does_not_block ... [OK]
    test_find_credentials_with_error_cb ... [OK]
    test_find_credentials_with_success_cb ... [OK]
    test_handles_error ... [OK]
  CredentialsManagementOpsTestCase
    test_login ... [OK]
    test_login_email_password ... [OK]
    test_register ... [OK]
  CredentialsManagementParamsTestCase
    test_login ... [OK]
    test_login_email_password ... [OK]
    test_register ... [OK]
  CredentialsManagementRefCountingTestCase
    test_authorization_denied ... [OK]
    test_autorization_denied_when_ref_count_is_not_positive ... [OK]
    test_clear_credentials ... [OK]
    test_credentials_cleared ... [OK]
    test_credentials_cleared_when_ref_count_is_not_positive ... [OK]
    test_credentials_error ... [OK]
    test_credentials_error_when_ref_count_is_not_positive ... [OK]
    test_credentials_found ... [OK]
    test_credentials_found_when_ref_count_is_not_positive ... [OK]
    test_credentials_not_found ... [OK]
    test_credentials_not_found_when_ref_count_is_not_positive ... [OK]
    test_credentials_stored ... [OK]
    test_credentials_stored_when_ref_count_is_not_positive ... [OK]
    test_find_credentials ... ...

968. By Manuel de la Peña on 2012-06-19

Fix lint issues.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'ubuntu_sso/utils/tcpactivation.py'
2--- ubuntu_sso/utils/tcpactivation.py 2012-05-03 11:42:55 +0000
3+++ ubuntu_sso/utils/tcpactivation.py 2012-06-19 16:18:19 +0000
4@@ -87,11 +87,13 @@
5
6 def clientConnectionLost(self, connector, reason):
7 """The connection was lost."""
8+ protocol.ClientFactory.clientConnectionLost(self, connector, reason)
9 if not self.d.called:
10 self.d.callback(False)
11
12 def clientConnectionFailed(self, connector, reason):
13 """The connection failed."""
14+ protocol.ClientFactory.clientConnectionFailed(self, connector, reason)
15 if not self.d.called:
16 self.d.callback(False)
17
18
19=== modified file 'ubuntu_sso/utils/tests/test_tcpactivation.py'
20--- ubuntu_sso/utils/tests/test_tcpactivation.py 2012-05-03 12:36:08 +0000
21+++ ubuntu_sso/utils/tests/test_tcpactivation.py 2012-06-19 16:18:19 +0000
22@@ -72,7 +72,7 @@
23 self.transport.write(data)
24
25
26-class FakeServerFactory(protocol.Factory):
27+class FakeServerFactory(protocol.ServerFactory):
28 """A factory for the test server."""
29
30 protocol = FakeServerProtocol
31@@ -97,37 +97,6 @@
32 self.client = client_description
33
34
35-class FakeConnectedClient(object):
36- """Fake class use to patch connections."""
37-
38- def __init__(self, testcase, inner):
39- """Create a new instance."""
40- self.testcase = testcase
41- self.inner = inner
42-
43- @defer.inlineCallbacks
44- def connect(self, factory):
45- """Connect using the given factory."""
46- # we need to get the class of the factory and patch it
47- yield self.testcase.connect_client(PortDetectFactory)
48- self.inner.factory = self.testcase.client_factory
49- defer.returnValue(self.testcase.connector)
50-
51-
52-class WrapperFactory(object):
53- """Wrapps a factory so that it can be replaced in a test."""
54-
55- def __init__(self, factory):
56- self.factory = None
57-
58- def __call__(self, *args, **kwargs):
59- return self
60-
61- def is_listening(self):
62- """Return if the service is listening."""
63- return self.factory.is_listening()
64-
65-
66 class AsyncSleepTestCase(TestCase):
67 """Tests for the async_sleep function."""
68
69@@ -231,7 +200,7 @@
70 self.assertEqual(config.description, SAMPLE_CLIENT_DESCRIPTION)
71
72
73-class ActivationDetectorTestCase(ServerTestCase):
74+class ActivationDetectorTestCase(TestCase):
75 """Tests for the ActivationDetector class."""
76
77 timeoue = 3
78@@ -270,15 +239,29 @@
79 @defer.inlineCallbacks
80 def test_is_already_running(self):
81 """The is_already_running method returns True if already started."""
82- inner = WrapperFactory(None)
83-
84- self.patch(tcpactivation, 'PortDetectFactory', inner)
85- client = FakeConnectedClient(self, inner)
86+ server = self.get_server()
87+ self.addCleanup(server.clean_up)
88+
89+ class TestConnect(object):
90+ """A fake connection object."""
91+
92+ # pylint: disable=E0213
93+ @defer.inlineCallbacks
94+ def connect(my_self, factory):
95+ """A fake connection."""
96+
97+ connected_factory = yield server.connect_client(
98+ PortDetectFactory)
99+ self.patch(factory, 'is_listening',
100+ connected_factory.is_listening)
101+ defer.returnValue(connected_factory)
102+ # pylint: enable=E0213
103
104 self.patch(tcpactivation, 'clientFromString',
105- lambda *args: client)
106-
107- yield self.listen_server(FakeServerFactory)
108+ lambda *args: TestConnect())
109+
110+ yield server.listen_server(protocol.ServerFactory)
111+
112 # pylint: disable=E1101
113 ad = ActivationDetector(self.config)
114 result = yield ad.is_already_running()
115@@ -420,15 +403,28 @@
116 @defer.inlineCallbacks
117 def test_get_description_fails_if_service_already_started(self):
118 """The get_description method fails if service already started."""
119- inner = WrapperFactory(None)
120-
121- self.patch(tcpactivation, 'PortDetectFactory', inner)
122- client = FakeConnectedClient(self, inner)
123+ server = self.get_server()
124+ self.addCleanup(server.clean_up)
125+
126+ class TestConnect(object):
127+ """A fake connection object."""
128+
129+ # pylint: disable=E0213
130+ @defer.inlineCallbacks
131+ def connect(my_self, factory):
132+ """A fake connection."""
133+
134+ connected_factory = yield server.connect_client(
135+ PortDetectFactory)
136+ self.patch(factory, 'is_listening',
137+ connected_factory.is_listening)
138+ defer.returnValue(connected_factory)
139+ # pylint: enable=E0213
140
141 self.patch(tcpactivation, 'clientFromString',
142- lambda *args: client)
143+ lambda *args: TestConnect())
144
145- yield self.listen_server(FakeServerFactory)
146+ yield server.listen_server(protocol.ServerFactory)
147
148 ai = ActivationInstance(self.config)
149 yield self.assertFailure(ai.get_server_description(),

Subscribers

People subscribed via source and target branches