def test_shell_su_error(self): mock_adb = Mock() mock_adb.shell_command.return_value = "su_error" Adb.adb = mock_adb with pytest.raises(Adb.AdbError): Adb.shell_su(123, "test_command_su") expected_calls = [ call.set_target_by_name(123), call.shell_command('su -c \'test_command_su\'') ] assert mock_adb.mock_calls == expected_calls
def test_shell_su_succes(self): mock_adb = Mock() mock_adb.shell_command.return_value = "su_succes " Adb.adb = mock_adb result = Adb.shell_su(123, "test_command_su") expected_calls = [ call.set_target_by_name(123), call.shell_command('su -c \'test_command_su\'') ] assert mock_adb.mock_calls == expected_calls assert result == 'su_succes'