summaryrefslogtreecommitdiffstats
path: root/testing/mozbase/mozdevice/tests/test_is_app_installed.py
diff options
context:
space:
mode:
Diffstat (limited to 'testing/mozbase/mozdevice/tests/test_is_app_installed.py')
-rw-r--r--testing/mozbase/mozdevice/tests/test_is_app_installed.py38
1 files changed, 38 insertions, 0 deletions
diff --git a/testing/mozbase/mozdevice/tests/test_is_app_installed.py b/testing/mozbase/mozdevice/tests/test_is_app_installed.py
new file mode 100644
index 0000000000..a51836bc02
--- /dev/null
+++ b/testing/mozbase/mozdevice/tests/test_is_app_installed.py
@@ -0,0 +1,38 @@
+#!/usr/bin/env python
+
+import mozunit
+import pytest
+from mozdevice import ADBError
+
+
+def test_is_app_installed(mock_adb_object):
+ """Tests that is_app_installed returns True if app is installed."""
+ assert mock_adb_object.is_app_installed("org.mozilla.geckoview_example")
+
+
+def test_is_app_installed_not_installed(mock_adb_object):
+ """Tests that is_app_installed returns False if provided app_name
+ does not resolve."""
+ assert not mock_adb_object.is_app_installed("some_random_name")
+
+
+def test_is_app_installed_partial_name(mock_adb_object):
+ """Tests that is_app_installed returns False if provided app_name
+ is only a partial match."""
+ assert not mock_adb_object.is_app_installed("fennec")
+
+
+def test_is_app_installed_package_manager_error(mock_adb_object):
+ """Tests that is_app_installed is able to raise an exception."""
+ with pytest.raises(ADBError):
+ mock_adb_object.is_app_installed("error")
+
+
+def test_is_app_installed_no_installed_package_found(mock_adb_object):
+ """Tests that is_app_installed is able to handle scenario
+ where no installed packages are found."""
+ assert not mock_adb_object.is_app_installed("none")
+
+
+if __name__ == "__main__":
+ mozunit.main()