testing/mozbase/mozdevice/sut_tests/test_fileExists.py

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/testing/mozbase/mozdevice/sut_tests/test_fileExists.py	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,37 @@
     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 tempfile
     1.9 +import posixpath
    1.10 +
    1.11 +from dmunit import DeviceManagerTestCase
    1.12 +
    1.13 +class FileExistsTestCase(DeviceManagerTestCase):
    1.14 +    """This tests the "fileExists" command.
    1.15 +    """
    1.16 +
    1.17 +    def testOnRoot(self):
    1.18 +        self.assertTrue(self.dm.fileExists('/'))
    1.19 +
    1.20 +    def testOnNonexistent(self):
    1.21 +        self.assertFalse(self.dm.fileExists('/doesNotExist'))
    1.22 +
    1.23 +    def testOnRegularFile(self):
    1.24 +        remote_path = posixpath.join(self.dm.getDeviceRoot(), 'testFile')
    1.25 +        self.assertFalse(self.dm.fileExists(remote_path))
    1.26 +        with tempfile.NamedTemporaryFile() as f:
    1.27 +            self.dm.pushFile(f.name, remote_path)
    1.28 +        self.assertTrue(self.dm.fileExists(remote_path))
    1.29 +        self.dm.removeFile(remote_path)
    1.30 +
    1.31 +    def testOnDirectory(self):
    1.32 +        remote_path = posixpath.join(self.dm.getDeviceRoot(), 'testDir')
    1.33 +        remote_path_file = posixpath.join(remote_path, 'testFile')
    1.34 +        self.assertFalse(self.dm.fileExists(remote_path))
    1.35 +        with tempfile.NamedTemporaryFile() as f:
    1.36 +            self.dm.pushFile(f.name, remote_path_file)
    1.37 +        self.assertTrue(self.dm.fileExists(remote_path))
    1.38 +        self.dm.removeFile(remote_path_file)
    1.39 +        self.dm.removeDir(remote_path)
    1.40 +

mercurial