1414
1515import httpretty
1616
17+ from appium .webdriver .applicationstate import ApplicationState
1718from appium .webdriver .webdriver import WebDriver
1819from test .unit .helper .test_helper import (
1920 android_w3c_driver ,
@@ -36,3 +37,98 @@ def test_reset(self):
3637
3738 assert {'sessionId' : '1234567890' }, get_httpretty_request_body (httpretty .last_request ())
3839 assert isinstance (result , WebDriver )
40+
41+ @httpretty .activate
42+ def test_install_app (self ):
43+ driver = android_w3c_driver ()
44+ httpretty .register_uri (
45+ httpretty .POST ,
46+ appium_command ('/session/1234567890/appium/device/install_app' ),
47+ body = '{"value": ""}'
48+ )
49+ result = driver .install_app ('path/to/app' )
50+
51+ assert {'app' : 'path/to/app' }, get_httpretty_request_body (httpretty .last_request ())
52+ assert isinstance (result , WebDriver )
53+
54+ @httpretty .activate
55+ def test_remove_app (self ):
56+ driver = android_w3c_driver ()
57+ httpretty .register_uri (
58+ httpretty .POST ,
59+ appium_command ('/session/1234567890/appium/device/remove_app' ),
60+ body = '{"value": ""}'
61+ )
62+ result = driver .remove_app ('com.app.id' )
63+
64+ assert {'app' : 'com.app.id' }, get_httpretty_request_body (httpretty .last_request ())
65+ assert isinstance (result , WebDriver )
66+
67+ @httpretty .activate
68+ def test_app_installed (self ):
69+ driver = android_w3c_driver ()
70+ httpretty .register_uri (
71+ httpretty .POST ,
72+ appium_command ('/session/1234567890/appium/device/app_installed' ),
73+ body = '{"value": true}'
74+ )
75+ result = driver .is_app_installed ("com.app.id" )
76+ assert {'app' : "com.app.id" }, get_httpretty_request_body (httpretty .last_request ())
77+ assert result is True
78+
79+ @httpretty .activate
80+ def test_terminate_app (self ):
81+ driver = android_w3c_driver ()
82+ httpretty .register_uri (
83+ httpretty .POST ,
84+ appium_command ('/session/1234567890/appium/device/terminate_app' ),
85+ body = '{"value": true}'
86+ )
87+ result = driver .terminate_app ("com.app.id" )
88+ assert {'app' : "com.app.id" }, get_httpretty_request_body (httpretty .last_request ())
89+ assert result is True
90+
91+ @httpretty .activate
92+ def test_background_app (self ):
93+ driver = android_w3c_driver ()
94+ httpretty .register_uri (
95+ httpretty .POST ,
96+ appium_command ('/session/1234567890/appium/app/background' ),
97+ body = '{"value": ""}'
98+ )
99+ result = driver .background_app (0 )
100+ assert {'app' : 0 }, get_httpretty_request_body (httpretty .last_request ())
101+ assert isinstance (result , WebDriver )
102+
103+ @httpretty .activate
104+ def test_launch_app (self ):
105+ driver = android_w3c_driver ()
106+ httpretty .register_uri (
107+ httpretty .POST ,
108+ appium_command ('/session/1234567890/appium/app/launch' ),
109+ body = '{"value": }'
110+ )
111+ assert isinstance (driver .launch_app (), WebDriver )
112+
113+ @httpretty .activate
114+ def test_close_app (self ):
115+ driver = android_w3c_driver ()
116+ httpretty .register_uri (
117+ httpretty .POST ,
118+ appium_command ('/session/1234567890/appium/app/close' ),
119+ body = '{"value": }'
120+ )
121+ assert isinstance (driver .close_app (), WebDriver )
122+
123+ @httpretty .activate
124+ def test_query_app_state (self ):
125+ driver = android_w3c_driver ()
126+ httpretty .register_uri (
127+ httpretty .POST ,
128+ appium_command ('/session/1234567890/appium/device/app_state' ),
129+ body = '{"value": 3 }'
130+ )
131+ result = driver .query_app_state ('com.app.id' )
132+
133+ assert {'app' : 3 }, get_httpretty_request_body (httpretty .last_request ())
134+ assert result is ApplicationState .RUNNING_IN_BACKGROUND
0 commit comments