Thu, 15 Jan 2015 21:03:48 +0100
Integrate friendly tips from Tor colleagues to make (or not) 4.5 alpha 3;
This includes removal of overloaded (but unused) methods, and addition of
a overlooked call to DataStruct::SetData(nsISupports, uint32_t, bool.)
1 # This Source Code Form is subject to the terms of the Mozilla Public
2 # License, v. 2.0. If a copy of the MPL was not distributed with this
3 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
5 import hashlib
6 import os
7 import posixpath
9 from dmunit import DeviceManagerTestCase
10 from mozdevice.devicemanager import DMError
12 class PullTestCase(DeviceManagerTestCase):
14 def runTest(self):
15 """Tests the "pull" command with a binary file.
16 """
17 orig = hashlib.md5()
18 new = hashlib.md5()
19 local_test_file = os.path.join('test-files', 'mybinary.zip')
20 orig.update(file(local_test_file, 'r').read())
22 testroot = self.dm.getDeviceRoot()
23 remote_test_file = posixpath.join(testroot, 'mybinary.zip')
24 self.dm.removeFile(remote_test_file)
25 self.dm.pushFile(local_test_file, remote_test_file)
26 new.update(self.dm.pullFile(remote_test_file))
27 # Use hexdigest() instead of digest() since values are printed
28 # if assert fails
29 self.assertEqual(orig.hexdigest(), new.hexdigest())
31 remote_missing_file = posixpath.join(testroot, 'doesnotexist')
32 self.dm.removeFile(remote_missing_file) # Just to be sure
33 self.assertRaises(DMError, self.dm.pullFile, remote_missing_file)