testing/mozbase/mozdevice/sut_tests/test_fileExists.py

changeset 0
6474c204b198
equal deleted inserted replaced
-1:000000000000 0:ab15c22cbd92
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/.
4
5 import tempfile
6 import posixpath
7
8 from dmunit import DeviceManagerTestCase
9
10 class FileExistsTestCase(DeviceManagerTestCase):
11 """This tests the "fileExists" command.
12 """
13
14 def testOnRoot(self):
15 self.assertTrue(self.dm.fileExists('/'))
16
17 def testOnNonexistent(self):
18 self.assertFalse(self.dm.fileExists('/doesNotExist'))
19
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)
27
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)
37

mercurial