Merge lp:~mandel/ubuntuone-client/fix-803622 into lp:ubuntuone-client

Proposed by Manuel de la Peña
Status: Merged
Approved by: Natalia Bidart
Approved revision: 1036
Merged at revision: 1034
Proposed branch: lp:~mandel/ubuntuone-client/fix-803622
Merge into: lp:ubuntuone-client
Diff against target: 64 lines (+29/-2)
2 files modified
tests/syncdaemon/test_action_queue.py (+28/-1)
ubuntuone/syncdaemon/action_queue.py (+1/-1)
To merge this branch: bzr merge lp:~mandel/ubuntuone-client/fix-803622
Reviewer Review Type Date Requested Status
Natalia Bidart (community) Approve
Guillermo Gonzalez Approve
Review via email: mp+66425@code.launchpad.net

Commit message

Ensure that we use the correct mode when opening files: r+w is an illegal mode everywhere, and has been changed to w+b to ensure that it works on all platforms (LP: #803622).

Description of the change

Ensure that we use the correct mode. r+w is an illegal mode verywhere and has been changed to w+b to ensure that it will work on all platforms.

In order to run the tests on windows please do:

python C:\Python27\Scripts\u1trial tests\syncdaemon\test_action_queue.py -t test_fdopen

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

Test needed! :-)

review: Needs Fixing
1033. By Manuel de la Peña

Added test to ensure we use the correct mode.

1034. By Manuel de la Peña

Merged with changes form linux.

1035. By Manuel de la Peña

Added real test to ensure that we can read and write.

Revision history for this message
Guillermo Gonzalez (verterok) wrote :

+1

review: Approve
Revision history for this message
Natalia Bidart (nataliabidart) wrote :

== Python Lint Notices ==

./tests/syncdaemon/test_action_queue.py:
    5653: local variable 'tmp' is assigned to but never used

review: Needs Fixing
1036. By Manuel de la Peña

Remove unused var.

Revision history for this message
Natalia Bidart (nataliabidart) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'tests/syncdaemon/test_action_queue.py'
2--- tests/syncdaemon/test_action_queue.py 2011-05-31 15:23:02 +0000
3+++ tests/syncdaemon/test_action_queue.py 2011-06-30 15:03:26 +0000
4@@ -33,7 +33,7 @@
5
6 from functools import wraps
7
8-from mocker import Mocker
9+from mocker import Mocker, MockerTestCase, ANY
10 from StringIO import StringIO
11 from oauth import oauth
12 from twisted.internet import defer, threads, reactor
13@@ -65,6 +65,7 @@
14 TRANSFER_PROGRESS_THRESHOLD, Unlink, Move, MakeFile, MakeDir, DeltaList,
15 ZipQueue, DeferredMap, ThrottlingStorageClient, PathLockingTree,
16 InterruptibleDeferred, DeferredInterrupted, ConditionsLocker,
17+ NamedTemporaryFile
18 )
19 from ubuntuone.syncdaemon.event_queue import EventQueue, EVENTS
20 from ubuntuone.syncdaemon.marker import MDMarker
21@@ -5634,3 +5635,29 @@
22 # 1 should be released, 2 should not (even with conditions ok)
23 self.assertTrue(locking_d1.called)
24 self.assertFalse(locking_d2.called)
25+
26+
27+class OsIntegrationTests(BasicTestCase, MockerTestCase):
28+ """Ensure that the correct os_helper methods are used."""
29+
30+ def setUp(self):
31+ """Set up for tests."""
32+ super(OsIntegrationTests, self).setUp()
33+ self.fdopen = self.mocker.replace('os.fdopen')
34+
35+ def test_fdopen(self):
36+ """Ensure that we are calling fdopen correctly."""
37+ # set expectations
38+ self.fdopen(ANY, 'w+b')
39+ self.mocker.replay()
40+ NamedTemporaryFile()
41+
42+ def test_fdopen_real(self):
43+ """Do test that the NamedTeporaryFile can read and write."""
44+ data = 'test'
45+ self.mocker.replay()
46+ tmp = NamedTemporaryFile()
47+ tmp.write(data)
48+ tmp.seek(0)
49+ self.assertEqual(data, tmp.read(len(data)))
50+ tmp.close()
51\ No newline at end of file
52
53=== modified file 'ubuntuone/syncdaemon/action_queue.py'
54--- ubuntuone/syncdaemon/action_queue.py 2011-05-31 15:23:02 +0000
55+++ ubuntuone/syncdaemon/action_queue.py 2011-06-30 15:03:26 +0000
56@@ -230,7 +230,7 @@
57
58 def __init__(self):
59 fileno, self.name = tempfile.mkstemp()
60- self._fd = os.fdopen(fileno, 'r+w')
61+ self._fd = os.fdopen(fileno, 'w+b')
62
63 def __getattr__(self, attr):
64 """Proxy everything else (other than .name) on to self._fd."""

Subscribers

People subscribed via source and target branches