test_is_app_installed.py (1226B)
1 #!/usr/bin/env python 2 3 import mozunit 4 import pytest 5 from mozdevice import ADBError 6 7 8 def test_is_app_installed(mock_adb_object): 9 """Tests that is_app_installed returns True if app is installed.""" 10 assert mock_adb_object.is_app_installed("org.mozilla.geckoview_example") 11 12 13 def test_is_app_installed_not_installed(mock_adb_object): 14 """Tests that is_app_installed returns False if provided app_name 15 does not resolve.""" 16 assert not mock_adb_object.is_app_installed("some_random_name") 17 18 19 def test_is_app_installed_partial_name(mock_adb_object): 20 """Tests that is_app_installed returns False if provided app_name 21 is only a partial match.""" 22 assert not mock_adb_object.is_app_installed("fennec") 23 24 25 def test_is_app_installed_package_manager_error(mock_adb_object): 26 """Tests that is_app_installed is able to raise an exception.""" 27 with pytest.raises(ADBError): 28 mock_adb_object.is_app_installed("error") 29 30 31 def test_is_app_installed_no_installed_package_found(mock_adb_object): 32 """Tests that is_app_installed is able to handle scenario 33 where no installed packages are found.""" 34 assert not mock_adb_object.is_app_installed("none") 35 36 37 if __name__ == "__main__": 38 mozunit.main()