testing/mozbase/mozdevice/sut_tests/test_fileExists.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 tempfile
     6 import posixpath
     8 from dmunit import DeviceManagerTestCase
    10 class FileExistsTestCase(DeviceManagerTestCase):
    11     """This tests the "fileExists" command.
    12     """
    14     def testOnRoot(self):
    15         self.assertTrue(self.dm.fileExists('/'))
    17     def testOnNonexistent(self):
    18         self.assertFalse(self.dm.fileExists('/doesNotExist'))
    20     def testOnRegularFile(self):
    21         remote_path = posixpath.join(self.dm.getDeviceRoot(), 'testFile')
    22         self.assertFalse(self.dm.fileExists(remote_path))
    23         with tempfile.NamedTemporaryFile() as f:
    24             self.dm.pushFile(f.name, remote_path)
    25         self.assertTrue(self.dm.fileExists(remote_path))
    26         self.dm.removeFile(remote_path)
    28     def testOnDirectory(self):
    29         remote_path = posixpath.join(self.dm.getDeviceRoot(), 'testDir')
    30         remote_path_file = posixpath.join(remote_path, 'testFile')
    31         self.assertFalse(self.dm.fileExists(remote_path))
    32         with tempfile.NamedTemporaryFile() as f:
    33             self.dm.pushFile(f.name, remote_path_file)
    34         self.assertTrue(self.dm.fileExists(remote_path))
    35         self.dm.removeFile(remote_path_file)
    36         self.dm.removeDir(remote_path)

mercurial