Skip to content

Commit

Permalink
encapp: fix unittests in workflow by adding "debug=x"
Browse files Browse the repository at this point in the history
Signed-off-by: JohanBlome <[email protected]>
  • Loading branch information
JohanBlome committed Nov 20, 2024
1 parent 03c02bc commit b665e0b
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions scripts/tests/unit/adb_cmds_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ def test_get_device_info_with_single_device_not_specified_return_info(
def test_remove_files_using_regex_shall_remove_regex_match_files(self, mock_run):
mock_run.return_value = (True, ADB_LS_ENCAPP, "")
encapp_tool.adb_cmds.remove_files_using_regex(
ADB_DEVICE_VALID_ID, r"encapp_.*", "/sdcard", 1
ADB_DEVICE_VALID_ID, r"encapp_.*", "/sdcard", debug=1
)
mock_run.assert_has_calls(
[
Expand All @@ -139,23 +139,23 @@ def test_remove_files_using_regex_shall_remove_regex_match_files(self, mock_run)
def test_get_app_pid_active_process_shall_return_pid(self, mock_run):
mock_run.return_value = (True, "19519", "")
actual_pid = encapp_tool.adb_cmds.get_app_pid(
ADB_DEVICE_VALID_ID, "com.facebook.encapp", 0
ADB_DEVICE_VALID_ID, "com.facebook.encapp", debug=0
)
self.assertEqual(actual_pid, 19519)

@unittest.mock.patch("encapp_tool.adb_cmds.run_cmd")
def test_get_app_pid_inactive_process_shall_return_not_running_code(self, mock_run):
mock_run.return_value = (True, "", "")
actual_pid = encapp_tool.adb_cmds.get_app_pid(
ADB_DEVICE_VALID_ID, "com.facebook.encapp", 0
ADB_DEVICE_VALID_ID, "com.facebook.encapp", debug=0
)
self.assertEqual(actual_pid, -1)

@unittest.mock.patch("encapp_tool.adb_cmds.run_cmd")
def test_get_app_pid_invalid_id_output_shall_return_error_code(self, mock_run):
mock_run.return_value = (True, "INVALID", "")
actual_pid = encapp_tool.adb_cmds.get_app_pid(
ADB_DEVICE_VALID_ID, "com.facebook.encapp", 0
ADB_DEVICE_VALID_ID, "com.facebook.encapp", debug=0
)
self.assertEqual(actual_pid, -2)

Expand Down Expand Up @@ -188,7 +188,7 @@ def test_grant_storage_permission_shall_grant_external_storage_with_adb(
pm_grant_str = (
f"adb -s {ADB_DEVICE_VALID_ID} shell " "pm grant com.example.myapp "
)
encapp_tool.adb_cmds.grant_storage_permissions(ADB_DEVICE_VALID_ID, apk, 0)
encapp_tool.adb_cmds.grant_storage_permissions(ADB_DEVICE_VALID_ID, apk, debug=0)
mock_run.assert_has_calls(
[
unittest.mock.call(
Expand All @@ -211,13 +211,13 @@ def test_grant_storage_permission_shall_grant_external_storage_with_adb(
def test_force_stop_shall_use_am_to_stop_package(self, mock_run):
apk = "com.example.myapp"
expected_cmd = f"adb -s {ADB_DEVICE_VALID_ID} shell " f"am force-stop {apk}"
encapp_tool.adb_cmds.force_stop(ADB_DEVICE_VALID_ID, apk)
encapp_tool.adb_cmds.force_stop(ADB_DEVICE_VALID_ID, apk, debug=0)
mock_run.assert_called_with(expected_cmd, 0)

@unittest.mock.patch("encapp_tool.adb_cmds.run_cmd")
def test_installed_apps_shall_list_pm_list_packages(self, mock_run):
mock_run.return_value = (True, ADB_PM_LIST_OUT, "")
result = encapp_tool.adb_cmds.installed_apps(ADB_DEVICE_VALID_ID, 1)
result = encapp_tool.adb_cmds.installed_apps(ADB_DEVICE_VALID_ID, debug=1)
expect_out = [
"com.android.package.a",
"com.android.package.b",
Expand All @@ -237,11 +237,11 @@ def test_uninstall_apk_shall_uninstall_pkg_if_found(self, mock_installed, mock_r
]
mock_installed.return_value = installed_packages
encapp_tool.adb_cmds.uninstall_apk(
ADB_DEVICE_VALID_ID, "com.not.found.package", 0
ADB_DEVICE_VALID_ID, "com.not.found.package", debug=0
)
mock_run.assert_not_called()
encapp_tool.adb_cmds.uninstall_apk(
ADB_DEVICE_VALID_ID, "com.android.package.a", 1
ADB_DEVICE_VALID_ID, "com.android.package.a", debug=1
)
mock_run.assert_called_with(
f"adb -s {ADB_DEVICE_VALID_ID} uninstall com.android.package.a", 1
Expand Down

0 comments on commit b665e0b

Please sign in to comment.