Skip to content

Commit 9cdfe5c

Browse files
authored
test: cleanup functional tests and move to unit test to CI stable (#1024)
1 parent b8daf2c commit 9cdfe5c

File tree

7 files changed

+126
-233
lines changed

7 files changed

+126
-233
lines changed

.github/workflows/functional-test.yml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -99,13 +99,11 @@ jobs:
9999
name: func_test_android3
100100
- target: test/functional/android/finger_print_tests.py test/functional/android/screen_record_tests.py test/functional/android/settings_tests.py test/functional/android/chrome_tests.py
101101
name: func_test_android4
102-
- target: test/functional/android/context_switching_tests.py test/functional/android/remote_fs_tests.py
102+
- target: test/functional/android/remote_fs_tests.py
103103
name: func_test_android5
104104
- target: test/functional/android/common_tests.py test/functional/android/webelement_tests.py
105105
name: func_test_android6
106-
- target: test/functional/android/applications_tests.py
107-
name: func_test_android7
108-
- target: test/functional/android/network_connection_tests.py test/functional/android/log_event_tests.py test/functional/android/activities_tests.py test/functional/android/hw_actions_tests.py
106+
- target: test/functional/android/network_connection_tests.py test/functional/android/log_event_tests.py test/functional/android/hw_actions_tests.py
109107
name: func_test_android8
110108

111109
runs-on: ubuntu-latest

test/functional/android/activities_tests.py

Lines changed: 0 additions & 60 deletions
This file was deleted.

test/functional/android/applications_tests.py

Lines changed: 0 additions & 61 deletions
This file was deleted.

test/functional/android/context_switching_tests.py

Lines changed: 0 additions & 77 deletions
This file was deleted.

test/unit/webdriver/app_test.py

Lines changed: 74 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -23,84 +23,130 @@ class TestWebDriverApp(object):
2323
@httpretty.activate
2424
def test_install_app(self):
2525
driver = android_w3c_driver()
26-
httpretty.register_uri(
27-
httpretty.POST, appium_command('/session/1234567890/appium/device/install_app'), body='{"value": ""}'
28-
)
2926
httpretty.register_uri(httpretty.POST, appium_command('/session/1234567890/execute/sync'), body='{"value": ""}')
3027
result = driver.install_app('path/to/app')
3128

32-
assert {'app': 'path/to/app'}, get_httpretty_request_body(httpretty.last_request())
29+
assert {
30+
'args': [{'app': 'path/to/app', 'appPath': 'path/to/app'}],
31+
'script': 'mobile: installApp',
32+
} == get_httpretty_request_body(httpretty.last_request())
3333
assert isinstance(result, WebDriver)
3434

3535
@httpretty.activate
3636
def test_remove_app(self):
3737
driver = android_w3c_driver()
38-
httpretty.register_uri(
39-
httpretty.POST, appium_command('/session/1234567890/appium/device/remove_app'), body='{"value": ""}'
40-
)
4138
httpretty.register_uri(httpretty.POST, appium_command('/session/1234567890/execute/sync'), body='{"value": ""}')
4239
result = driver.remove_app('com.app.id')
4340

44-
assert {'app': 'com.app.id'}, get_httpretty_request_body(httpretty.last_request())
41+
assert {
42+
'args': [{'appId': 'com.app.id', 'bundleId': 'com.app.id'}],
43+
'script': 'mobile: removeApp',
44+
} == get_httpretty_request_body(httpretty.last_request())
4545
assert isinstance(result, WebDriver)
4646

4747
@httpretty.activate
4848
def test_app_installed(self):
4949
driver = android_w3c_driver()
50-
httpretty.register_uri(
51-
httpretty.POST, appium_command('/session/1234567890/appium/device/app_installed'), body='{"value": true}'
52-
)
5350
httpretty.register_uri(
5451
httpretty.POST, appium_command('/session/1234567890/execute/sync'), body='{"value": true}'
5552
)
5653
result = driver.is_app_installed("com.app.id")
57-
assert {'app': "com.app.id"}, get_httpretty_request_body(httpretty.last_request())
54+
55+
assert {
56+
'args': [{'appId': 'com.app.id', 'bundleId': 'com.app.id'}],
57+
'script': 'mobile: isAppInstalled',
58+
} == get_httpretty_request_body(httpretty.last_request())
5859
assert result is True
5960

6061
@httpretty.activate
6162
def test_terminate_app(self):
6263
driver = android_w3c_driver()
63-
httpretty.register_uri(
64-
httpretty.POST, appium_command('/session/1234567890/appium/device/terminate_app'), body='{"value": true}'
65-
)
6664
httpretty.register_uri(
6765
httpretty.POST, appium_command('/session/1234567890/execute/sync'), body='{"value": true}'
6866
)
6967
result = driver.terminate_app("com.app.id")
70-
assert {'app': "com.app.id"}, get_httpretty_request_body(httpretty.last_request())
68+
69+
assert {
70+
'args': [{'appId': 'com.app.id', 'bundleId': 'com.app.id'}],
71+
'script': 'mobile: terminateApp',
72+
} == get_httpretty_request_body(httpretty.last_request())
7173
assert result is True
7274

7375
@httpretty.activate
7476
def test_activate_app(self):
7577
driver = android_w3c_driver()
76-
httpretty.register_uri(
77-
httpretty.POST, appium_command('/session/1234567890/appium/device/activate_app'), body='{"value": ""}'
78-
)
7978
httpretty.register_uri(httpretty.POST, appium_command('/session/1234567890/execute/sync'), body='{"value": ""}')
8079
result = driver.activate_app("com.app.id")
8180

82-
assert {'app': 'com.app.id'}, get_httpretty_request_body(httpretty.last_request())
81+
assert {
82+
'args': [{'appId': 'com.app.id', 'bundleId': 'com.app.id'}],
83+
'script': 'mobile: activateApp',
84+
} == get_httpretty_request_body(httpretty.last_request())
8385
assert isinstance(result, WebDriver)
8486

8587
@httpretty.activate
8688
def test_background_app(self):
8789
driver = android_w3c_driver()
88-
httpretty.register_uri(
89-
httpretty.POST, appium_command('/session/1234567890/appium/app/background'), body='{"value": ""}'
90-
)
9190
httpretty.register_uri(httpretty.POST, appium_command('/session/1234567890/execute/sync'), body='{"value": ""}')
9291
result = driver.background_app(0)
93-
assert {'app': 0}, get_httpretty_request_body(httpretty.last_request())
92+
93+
assert {'args': [{'seconds': 0}], 'script': 'mobile: backgroundApp'} == get_httpretty_request_body(
94+
httpretty.last_request()
95+
)
9496
assert isinstance(result, WebDriver)
9597

9698
@httpretty.activate
9799
def test_query_app_state(self):
98100
driver = android_w3c_driver()
99-
httpretty.register_uri(
100-
httpretty.POST, appium_command('/session/1234567890/appium/device/app_state'), body='{"value": 3 }'
101-
)
102101
httpretty.register_uri(httpretty.POST, appium_command('/session/1234567890/execute/sync'), body='{"value": 3}')
103102
result = driver.query_app_state('com.app.id')
104103

105-
assert {'app': 3}, get_httpretty_request_body(httpretty.last_request())
104+
assert {
105+
'args': [{'appId': 'com.app.id', 'bundleId': 'com.app.id'}],
106+
'script': 'mobile: queryAppState',
107+
} == get_httpretty_request_body(httpretty.last_request())
106108
assert result is ApplicationState.RUNNING_IN_BACKGROUND
109+
110+
@httpretty.activate
111+
def test_app_strings(self):
112+
driver = android_w3c_driver()
113+
httpretty.register_uri(
114+
httpretty.POST,
115+
appium_command('/session/1234567890/execute/sync'),
116+
body='{"value": {"monkey_wipe_data": "You can\'t wipe my data, you are a monkey!"} }',
117+
)
118+
result = driver.app_strings()
119+
120+
assert {'args': [{}], 'script': 'mobile: getAppStrings'} == get_httpretty_request_body(httpretty.last_request())
121+
assert 'You can\'t wipe my data, you are a monkey!' == result['monkey_wipe_data'], result
122+
123+
@httpretty.activate
124+
def test_app_strings_with_lang(self):
125+
driver = android_w3c_driver()
126+
httpretty.register_uri(
127+
httpretty.POST,
128+
appium_command('/session/1234567890/execute/sync'),
129+
body='{"value": {"monkey_wipe_data": "You can\'t wipe my data, you are a monkey!"} }',
130+
)
131+
result = driver.app_strings('en')
132+
133+
assert {'args': [{'language': 'en'}], 'script': 'mobile: getAppStrings'} == get_httpretty_request_body(
134+
httpretty.last_request()
135+
)
136+
assert 'You can\'t wipe my data, you are a monkey!' == result['monkey_wipe_data'], result
137+
138+
@httpretty.activate
139+
def test_app_strings_with_lang_and_file(self):
140+
driver = android_w3c_driver()
141+
httpretty.register_uri(
142+
httpretty.POST,
143+
appium_command('/session/1234567890/execute/sync'),
144+
body='{"value": {"monkey_wipe_data": "You can\'t wipe my data, you are a monkey!"} }',
145+
)
146+
result = driver.app_strings('en', 'some_file')
147+
148+
assert {
149+
'args': [{'language': 'en', 'stringFile': 'some_file'}],
150+
'script': 'mobile: getAppStrings',
151+
} == get_httpretty_request_body(httpretty.last_request())
152+
assert 'You can\'t wipe my data, you are a monkey!' == result['monkey_wipe_data'], result

0 commit comments

Comments
 (0)