testing/mozbase/mozdevice/sut_tests/test_pull.py

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     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)

mercurial