testing/mozbase/mozdevice/tests/sut_movetree.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 #!/usr/bin/env python
     2 # -*- coding: utf-8 -*-
     4 # This Source Code Form is subject to the terms of the Mozilla Public
     5 # License, v. 2.0. If a copy of the MPL was not distributed with this file,
     6 # You can obtain one at http://mozilla.org/MPL/2.0/.
     8 import mozdevice
     9 import mozlog
    10 import unittest
    11 from sut import MockAgent
    13 class MoveTreeTest(unittest.TestCase):
    14     def test_moveFile(self):
    15         commands = [('mv /mnt/sdcard/tests/test.txt /mnt/sdcard/tests/test1.txt', ''),
    16                     ('isdir /mnt/sdcard/tests', 'TRUE'),
    17                     ('cd /mnt/sdcard/tests', ''),
    18                     ('ls', 'test1.txt'),
    19                     ('isdir /mnt/sdcard/tests', 'TRUE'),
    20                     ('cd /mnt/sdcard/tests', ''),
    21                     ('ls', 'test1.txt')]
    23         m = MockAgent(self, commands=commands)
    24         d = mozdevice.DroidSUT("127.0.0.1", port=m.port, logLevel=mozlog.DEBUG)
    25         self.assertEqual(None, d.moveTree('/mnt/sdcard/tests/test.txt',
    26                 '/mnt/sdcard/tests/test1.txt'))
    27         self.assertFalse(d.fileExists('/mnt/sdcard/tests/test.txt'))
    28         self.assertTrue(d.fileExists('/mnt/sdcard/tests/test1.txt'))
    30     def test_moveDir(self):
    31         commands = [("mv /mnt/sdcard/tests/foo /mnt/sdcard/tests/bar", ""),
    32                     ('isdir /mnt/sdcard/tests', 'TRUE'),
    33                     ('cd /mnt/sdcard/tests', ''),
    34                     ('ls', 'bar')]
    36         m = MockAgent(self, commands=commands)
    37         d = mozdevice.DroidSUT("127.0.0.1", port=m.port, logLevel=mozlog.DEBUG)
    38         self.assertEqual(None, d.moveTree('/mnt/sdcard/tests/foo',
    39                 '/mnt/sdcard/tests/bar'))
    40         self.assertTrue(d.fileExists('/mnt/sdcard/tests/bar'))
    42     def test_moveNonEmptyDir(self):
    43         commands = [('isdir /mnt/sdcard/tests/foo/bar', 'TRUE'),
    44                     ('mv /mnt/sdcard/tests/foo /mnt/sdcard/tests/foo2', ''),
    45                     ('isdir /mnt/sdcard/tests', 'TRUE'),
    46                     ('cd /mnt/sdcard/tests', ''),
    47                     ('ls', 'foo2'),
    48                     ('isdir /mnt/sdcard/tests/foo2', 'TRUE'),
    49                     ('cd /mnt/sdcard/tests/foo2', ''),
    50                     ('ls', 'bar')]
    52         m = MockAgent(self, commands=commands)
    53         d = mozdevice.DroidSUT("127.0.0.1", port=m.port,
    54                 logLevel=mozlog.DEBUG)
    56         self.assertTrue(d.dirExists('/mnt/sdcard/tests/foo/bar'))
    57         self.assertEqual(None, d.moveTree('/mnt/sdcard/tests/foo',
    58                 '/mnt/sdcard/tests/foo2'))
    59         self.assertTrue(d.fileExists('/mnt/sdcard/tests/foo2'))
    60         self.assertTrue(d.fileExists('/mnt/sdcard/tests/foo2/bar'))
    62 if __name__ == "__main__":
    63     unittest.main()

mercurial