diff options
author | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
---|---|---|
committer | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
commit | 5f8de423f190bbb79a62f804151bc24824fa32d8 (patch) | |
tree | 10027f336435511475e392454359edea8e25895d /testing/mozbase/mozdevice/tests/sut_mkdir.py | |
parent | 49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff) | |
download | UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip |
Add m-esr52 at 52.6.0
Diffstat (limited to 'testing/mozbase/mozdevice/tests/sut_mkdir.py')
-rw-r--r-- | testing/mozbase/mozdevice/tests/sut_mkdir.py | 78 |
1 files changed, 78 insertions, 0 deletions
diff --git a/testing/mozbase/mozdevice/tests/sut_mkdir.py b/testing/mozbase/mozdevice/tests/sut_mkdir.py new file mode 100644 index 000000000..bacaae324 --- /dev/null +++ b/testing/mozbase/mozdevice/tests/sut_mkdir.py @@ -0,0 +1,78 @@ +# Any copyright is dedicated to the Public Domain. +# http://creativecommons.org/publicdomain/zero/1.0/ + +import mozdevice +import logging +import unittest +from sut import MockAgent + + +class MkDirsTest(unittest.TestCase): + + def test_mkdirs(self): + subTests = [{'cmds': [('isdir /mnt/sdcard/baz/boop', 'FALSE'), + ('info os', 'android'), + ('isdir /mnt', 'TRUE'), + ('isdir /mnt/sdcard', 'TRUE'), + ('isdir /mnt/sdcard/baz', 'FALSE'), + ('mkdr /mnt/sdcard/baz', + '/mnt/sdcard/baz successfully created'), + ('isdir /mnt/sdcard/baz/boop', 'FALSE'), + ('mkdr /mnt/sdcard/baz/boop', + '/mnt/sdcard/baz/boop successfully created')], + 'expectException': False}, + {'cmds': [('isdir /mnt/sdcard/baz/boop', 'FALSE'), + ('info os', 'android'), + ('isdir /mnt', 'TRUE'), + ('isdir /mnt/sdcard', 'TRUE'), + ('isdir /mnt/sdcard/baz', 'FALSE'), + ('mkdr /mnt/sdcard/baz', + "##AGENT-WARNING## " + "Could not create the directory /mnt/sdcard/baz")], + 'expectException': True}, + ] + for subTest in subTests: + a = MockAgent(self, commands=subTest['cmds']) + + exceptionThrown = False + try: + d = mozdevice.DroidSUT('127.0.0.1', port=a.port, + logLevel=logging.DEBUG) + d.mkDirs('/mnt/sdcard/baz/boop/bip') + except mozdevice.DMError: + exceptionThrown = True + self.assertEqual(exceptionThrown, subTest['expectException']) + + a.wait() + + def test_repeated_path_part(self): + """ + Ensure that all dirs are created when last path part also found + earlier in the path (bug 826492). + """ + + cmds = [('isdir /mnt/sdcard/foo', 'FALSE'), + ('info os', 'android'), + ('isdir /mnt', 'TRUE'), + ('isdir /mnt/sdcard', 'TRUE'), + ('isdir /mnt/sdcard/foo', 'FALSE'), + ('mkdr /mnt/sdcard/foo', + '/mnt/sdcard/foo successfully created')] + a = MockAgent(self, commands=cmds) + d = mozdevice.DroidSUT('127.0.0.1', port=a.port, + logLevel=logging.DEBUG) + d.mkDirs('/mnt/sdcard/foo/foo') + a.wait() + + def test_mkdirs_on_root(self): + cmds = [('isdir /', 'TRUE')] + a = MockAgent(self, commands=cmds) + d = mozdevice.DroidSUT('127.0.0.1', port=a.port, + logLevel=logging.DEBUG) + d.mkDirs('/foo') + + a.wait() + + +if __name__ == '__main__': + unittest.main() |