Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add unit tests for application_tests #454

Merged
merged 4 commits into from
Oct 19, 2019
Merged
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
96 changes: 96 additions & 0 deletions test/unit/webdriver/app_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

import httpretty

from appium.webdriver.applicationstate import ApplicationState
from appium.webdriver.webdriver import WebDriver
from test.unit.helper.test_helper import (
android_w3c_driver,
Expand All @@ -36,3 +37,98 @@ def test_reset(self):

assert {'sessionId': '1234567890'}, get_httpretty_request_body(httpretty.last_request())
assert isinstance(result, WebDriver)

@httpretty.activate
def test_install_app(self):
driver = android_w3c_driver()
httpretty.register_uri(
httpretty.POST,
appium_command('/session/1234567890/appium/device/install_app'),
body='{"value": ""}'
)
result = driver.install_app('path/to/app')

assert {'app': 'path/to/app'}, get_httpretty_request_body(httpretty.last_request())
assert isinstance(result, WebDriver)

@httpretty.activate
def test_remove_app(self):
driver = android_w3c_driver()
httpretty.register_uri(
httpretty.POST,
appium_command('/session/1234567890/appium/device/remove_app'),
body='{"value": ""}'
)
result = driver.remove_app('com.app.id')

assert {'app': 'com.app.id'}, get_httpretty_request_body(httpretty.last_request())
assert isinstance(result, WebDriver)

@httpretty.activate
def test_app_installed(self):
driver = android_w3c_driver()
httpretty.register_uri(
httpretty.POST,
appium_command('/session/1234567890/appium/device/app_installed'),
body='{"value": true}'
)
result = driver.is_app_installed("com.app.id")
assert {'app': "com.app.id"}, get_httpretty_request_body(httpretty.last_request())
assert result is True

@httpretty.activate
def test_terminate_app(self):
driver = android_w3c_driver()
httpretty.register_uri(
httpretty.POST,
appium_command('/session/1234567890/appium/device/terminate_app'),
body='{"value": true}'
)
result = driver.terminate_app("com.app.id")
assert {'app': "com.app.id"}, get_httpretty_request_body(httpretty.last_request())
assert result is True

@httpretty.activate
def test_background_app(self):
driver = android_w3c_driver()
httpretty.register_uri(
httpretty.POST,
appium_command('/session/1234567890/appium/app/background'),
body='{"value": ""}'
)
result = driver.background_app(0)
assert {'app': 0}, get_httpretty_request_body(httpretty.last_request())
assert isinstance(result, WebDriver)

@httpretty.activate
def test_launch_app(self):
driver = android_w3c_driver()
httpretty.register_uri(
httpretty.POST,
appium_command('/session/1234567890/appium/app/launch'),
body='{"value": }'
)
assert isinstance(driver.launch_app(), WebDriver)

@httpretty.activate
def test_close_app(self):
driver = android_w3c_driver()
httpretty.register_uri(
httpretty.POST,
appium_command('/session/1234567890/appium/app/close'),
body='{"value": }'
)
assert isinstance(driver.close_app(), WebDriver)

@httpretty.activate
def test_query_app_state(self):
driver = android_w3c_driver()
httpretty.register_uri(
httpretty.POST,
appium_command('/session/1234567890/appium/device/app_state'),
body='{"value": 3 }'
)
result = driver.query_app_state('com.app.id')

assert {'app': 3}, get_httpretty_request_body(httpretty.last_request())
assert result is ApplicationState.RUNNING_IN_BACKGROUND