testing/mozbase/mozdevice/sut_tests/test_pull.py

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

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)

mercurial