Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | # This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 2 | # License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 3 | # file, You can obtain one at http://mozilla.org/MPL/2.0/. |
michael@0 | 4 | |
michael@0 | 5 | import hashlib |
michael@0 | 6 | import os |
michael@0 | 7 | import posixpath |
michael@0 | 8 | |
michael@0 | 9 | from dmunit import DeviceManagerTestCase |
michael@0 | 10 | from mozdevice.devicemanager import DMError |
michael@0 | 11 | |
michael@0 | 12 | class PullTestCase(DeviceManagerTestCase): |
michael@0 | 13 | |
michael@0 | 14 | def runTest(self): |
michael@0 | 15 | """Tests the "pull" command with a binary file. |
michael@0 | 16 | """ |
michael@0 | 17 | orig = hashlib.md5() |
michael@0 | 18 | new = hashlib.md5() |
michael@0 | 19 | local_test_file = os.path.join('test-files', 'mybinary.zip') |
michael@0 | 20 | orig.update(file(local_test_file, 'r').read()) |
michael@0 | 21 | |
michael@0 | 22 | testroot = self.dm.getDeviceRoot() |
michael@0 | 23 | remote_test_file = posixpath.join(testroot, 'mybinary.zip') |
michael@0 | 24 | self.dm.removeFile(remote_test_file) |
michael@0 | 25 | self.dm.pushFile(local_test_file, remote_test_file) |
michael@0 | 26 | new.update(self.dm.pullFile(remote_test_file)) |
michael@0 | 27 | # Use hexdigest() instead of digest() since values are printed |
michael@0 | 28 | # if assert fails |
michael@0 | 29 | self.assertEqual(orig.hexdigest(), new.hexdigest()) |
michael@0 | 30 | |
michael@0 | 31 | remote_missing_file = posixpath.join(testroot, 'doesnotexist') |
michael@0 | 32 | self.dm.removeFile(remote_missing_file) # Just to be sure |
michael@0 | 33 | self.assertRaises(DMError, self.dm.pullFile, remote_missing_file) |