1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/testing/mozbase/mozdevice/sut_tests/test_pull.py Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,33 @@ 1.4 +# This Source Code Form is subject to the terms of the Mozilla Public 1.5 +# License, v. 2.0. If a copy of the MPL was not distributed with this 1.6 +# file, You can obtain one at http://mozilla.org/MPL/2.0/. 1.7 + 1.8 +import hashlib 1.9 +import os 1.10 +import posixpath 1.11 + 1.12 +from dmunit import DeviceManagerTestCase 1.13 +from mozdevice.devicemanager import DMError 1.14 + 1.15 +class PullTestCase(DeviceManagerTestCase): 1.16 + 1.17 + def runTest(self): 1.18 + """Tests the "pull" command with a binary file. 1.19 + """ 1.20 + orig = hashlib.md5() 1.21 + new = hashlib.md5() 1.22 + local_test_file = os.path.join('test-files', 'mybinary.zip') 1.23 + orig.update(file(local_test_file, 'r').read()) 1.24 + 1.25 + testroot = self.dm.getDeviceRoot() 1.26 + remote_test_file = posixpath.join(testroot, 'mybinary.zip') 1.27 + self.dm.removeFile(remote_test_file) 1.28 + self.dm.pushFile(local_test_file, remote_test_file) 1.29 + new.update(self.dm.pullFile(remote_test_file)) 1.30 + # Use hexdigest() instead of digest() since values are printed 1.31 + # if assert fails 1.32 + self.assertEqual(orig.hexdigest(), new.hexdigest()) 1.33 + 1.34 + remote_missing_file = posixpath.join(testroot, 'doesnotexist') 1.35 + self.dm.removeFile(remote_missing_file) # Just to be sure 1.36 + self.assertRaises(DMError, self.dm.pullFile, remote_missing_file)