Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 1 addition & 37 deletions test/functional/android/appium_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import base64
import unittest
from zipfile import ZipFile
import os
import random
from time import sleep
from dateutil.parser import parse

Expand All @@ -42,10 +39,6 @@ def setUp(self):
def tearDown(self):
self.driver.quit()

# remove zipped file from `test_pull_folder`
if hasattr(self, 'zipfilename') and os.path.isfile(self.zipfilename):
os.remove(self.zipfilename)

def test_screen_record(self):
self.driver.start_recording_screen(timeLimit=10, forcedRestart=True)
sleep(10)
Expand Down Expand Up @@ -99,35 +92,6 @@ def test_current_package(self):
package = self.driver.current_package
self.assertEqual('com.example.android.apis', package)

def test_push_pull_file(self):
path = '/data/local/tmp/test_push_file.txt'
data = b'This is the contents of the file to push to the device.'

self.driver.push_file(path, base64.b64encode(data).decode('utf-8'))
data_ret = base64.b64decode(self.driver.pull_file(path))

self.assertEqual(data, data_ret)

def test_pull_folder(self):
string_data = b'random string data %d' % random.randint(0, 1000)
path = '/data/local/tmp'

self.driver.push_file(path + '/1.txt', base64.b64encode(string_data).decode('utf-8'))
self.driver.push_file(path + '/2.txt', base64.b64encode(string_data).decode('utf-8'))

folder = self.driver.pull_folder(path)

# python doesn't have any functionality for unzipping streams
# save temporary file, which will be deleted in `tearDown`
self.zipfilename = 'folder_%d.zip' % random.randint(0, 1000000)
with open(self.zipfilename, "wb") as fw:
fw.write(base64.b64decode(folder))

with ZipFile(self.zipfilename, 'r') as myzip:
# should find these. otherwise it will raise a `KeyError`
myzip.read('1.txt')
myzip.read('2.txt')

def test_background_app(self):
self.driver.background_app(1)
sleep(3)
Expand Down Expand Up @@ -257,6 +221,6 @@ def test_device_time(self):
parse(date_time)


if __name__ == "__main__":
if __name__ == '__main__':
suite = unittest.TestLoader().loadTestsFromTestCase(AppiumTests)
unittest.TextTestRunner(verbosity=2).run(suite)
2 changes: 1 addition & 1 deletion test/functional/android/chrome_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,6 @@ def test_find_single_element(self):
self.assertTrue('I am some other page content' in self.driver.page_source)


if __name__ == "__main__":
if __name__ == '__main__':
suite = unittest.TestLoader().loadTestsFromTestCase(ChromeTests)
unittest.TextTestRunner(verbosity=2).run(suite)
2 changes: 1 addition & 1 deletion test/functional/android/context_switching_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,6 @@ def _enter_webview(self):
self.driver.switch_to.context('WEBVIEW')


if __name__ == "__main__":
if __name__ == '__main__':
suite = unittest.TestLoader().loadTestsFromTestCase(ContextSwitchingTests)
unittest.TextTestRunner(verbosity=2).run(suite)
2 changes: 1 addition & 1 deletion test/functional/android/find_by_accessibility_id_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,6 @@ def test_element_find_multiple_elements(self):
self.assertIsInstance(sub_els, list)


if __name__ == "__main__":
if __name__ == '__main__':
suite = unittest.TestLoader().loadTestsFromTestCase(FindByAccessibilityIDTests)
unittest.TextTestRunner(verbosity=2).run(suite)
2 changes: 1 addition & 1 deletion test/functional/android/find_by_image_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,6 @@ def test_find_throws_no_such_element(self):
self.driver.find_element_by_image(image_path)


if __name__ == "__main__":
if __name__ == '__main__':
suite = unittest.TestLoader().loadTestsFromTestCase(FindByImageTests)
unittest.TextTestRunner(verbosity=2).run(suite)
2 changes: 1 addition & 1 deletion test/functional/android/find_by_uiautomator_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,6 @@ def test_scroll_into_view(self):
el.click()


if __name__ == "__main__":
if __name__ == '__main__':
suite = unittest.TestLoader().loadTestsFromTestCase(FindByUIAutomatorTests)
unittest.TextTestRunner(verbosity=2).run(suite)
2 changes: 1 addition & 1 deletion test/functional/android/finger_print_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,6 @@ def test_finger_print(self):
self.assertEqual(None, result)


if __name__ == "__main__":
if __name__ == '__main__':
suite = unittest.TestLoader().loadTestsFromTestCase(FingerPrintTests)
unittest.TextTestRunner(verbosity=2).run(suite)
2 changes: 1 addition & 1 deletion test/functional/android/ime_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,6 @@ def test_deactivate_ime_engine(self):
self.assertNotEqual(self.driver.active_ime_engine, engines[-1])


if __name__ == "__main__":
if __name__ == '__main__':
suite = unittest.TestLoader().loadTestsFromTestCase(IMETests)
unittest.TextTestRunner(verbosity=2).run(suite)
2 changes: 1 addition & 1 deletion test/functional/android/multi_action_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,6 @@ def test_driver_multi_tap(self):
sleep(10)


if __name__ == "__main__":
if __name__ == '__main__':
suite = unittest.TestLoader().loadTestsFromTestCase(MultiActionTests)
unittest.TextTestRunner(verbosity=2).run(suite)
2 changes: 1 addition & 1 deletion test/functional/android/network_connection_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,6 @@ def test_set_network_connection(self):
self.assertEqual(nc, ConnectionType.DATA_ONLY)


if __name__ == "__main__":
if __name__ == '__main__':
suite = unittest.TestLoader().loadTestsFromTestCase(NetworkConnectionTests)
unittest.TextTestRunner(verbosity=2).run(suite)
46 changes: 0 additions & 46 deletions test/functional/android/push_file_tests.py

This file was deleted.

73 changes: 73 additions & 0 deletions test/functional/android/remote_fs_tests.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
#!/usr/bin/env python

# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import base64
import os
import random
import unittest
from io import BytesIO
from zipfile import ZipFile

from appium import webdriver
from appium.common.helper import appium_bytes
import desired_capabilities


class RemoteFsTests(unittest.TestCase):
def setUp(self):
desired_caps = desired_capabilities.get_desired_capabilities('ApiDemos-debug.apk')
self.driver = webdriver.Remote('http://localhost:4723/wd/hub', desired_caps)

def tearDown(self):
self.driver.quit()

def test_push_pull_file(self):
dest_path = '/data/local/tmp/test_push_file.txt'
data = appium_bytes('This is the contents of the file to push to the device.', 'utf-8')

self.driver.push_file(dest_path, base64.b64encode(data).decode('utf-8'))
data_ret = base64.b64decode(self.driver.pull_file(dest_path))

self.assertEqual(data, data_ret)

def test_pull_folder(self):
data = appium_bytes('random string data {}'.format(random.randint(0, 1000)), 'utf-8')
dest_dir = '/data/local/tmp/'

for filename in ['1.txt', '2.txt']:
self.driver.push_file(os.path.join(dest_dir, filename), base64.b64encode(data).decode('utf-8'))

folder = self.driver.pull_folder(dest_dir)

with ZipFile(BytesIO(base64.b64decode(folder))) as fzip:
for filename in ['1.txt', '2.txt']:
self.assertTrue(filename in fzip.namelist())

def test_push_file_with_src_path(self):
test_files = ['test_image.jpg', 'test_file.txt']
for file_name in test_files:
src_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), file_name)
dest_path = os.path.join('/data/local/tmp/', file_name)

with open(src_path, 'rb') as fr:
original_data = fr.read()

self.driver.push_file(dest_path, source_path=src_path)
new_data = base64.b64decode(self.driver.pull_file(dest_path))
self.assertEqual(original_data, new_data)


if __name__ == '__main__':
suite = unittest.TestLoader().loadTestsFromTestCase(RemoteFsTests)
unittest.TextTestRunner(verbosity=2).run(suite)
50 changes: 0 additions & 50 deletions test/functional/android/selendroid_tests.py

This file was deleted.

2 changes: 1 addition & 1 deletion test/functional/android/touch_action_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,6 @@ def test_driver_swipe(self):
self.assertIsNotNone(el)


if __name__ == "__main__":
if __name__ == '__main__':
suite = unittest.TestLoader().loadTestsFromTestCase(TouchActionTests)
unittest.TextTestRunner(verbosity=2).run(suite)