-
-
Notifications
You must be signed in to change notification settings - Fork 366
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
51 additions
and
100 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,27 @@ | ||
import subprocess | ||
from unittest.mock import Mock | ||
|
||
from briefcase.integrations.android_sdk import ADB | ||
|
||
|
||
def test_pid_exists_succeed(mock_tools): | ||
def test_pid_exists_succeed(adb): | ||
"""adb.pid_exists() can be called on a process that exists.""" | ||
adb = ADB(mock_tools, "exampleDevice") | ||
adb.run = Mock(return_value="") | ||
|
||
assert adb.pid_exists("1234") | ||
adb.run.assert_called_once_with("shell", "test", "-e", "/proc/1234") | ||
|
||
|
||
def test_pid_exists_quiet(mock_tools): | ||
def test_pid_exists_quiet(adb): | ||
"""adb.pid_exists() can be called in quiet mode on a process that exists.""" | ||
adb = ADB(mock_tools, "exampleDevice") | ||
adb.run = Mock(return_value="") | ||
|
||
assert adb.pid_exists("1234", quiet=True) | ||
adb.run.assert_called_once_with("shell", "test", "-e", "/proc/1234", quiet=True) | ||
|
||
|
||
def test_pid_does_not_exist(mock_tools): | ||
def test_pid_does_not_exist(adb): | ||
"""If adb.pid_exists() returns a status code of 1, it is interpreted as the process | ||
not existing.""" | ||
adb = ADB(mock_tools, "exampleDevice") | ||
adb.run = Mock(side_effect=subprocess.CalledProcessError(returncode=1, cmd="test")) | ||
|
||
assert not adb.pid_exists("9999") is None | ||
adb.run.assert_called_once_with("shell", "test", "-e", "/proc/9999") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,35 @@ | ||
import subprocess | ||
from unittest.mock import Mock | ||
|
||
from briefcase.integrations.android_sdk import ADB | ||
|
||
|
||
def test_pidof_succeed(mock_tools): | ||
def test_pidof_succeed(adb): | ||
"""adb.pidof() can be called on a process that exists.""" | ||
adb = ADB(mock_tools, "exampleDevice") | ||
adb.run = Mock(return_value="5678\n") | ||
|
||
assert adb.pidof("com.example") == "5678" | ||
adb.run.assert_called_once_with("shell", "pidof", "-s", "com.example") | ||
|
||
|
||
def test_pidof_quiet(mock_tools): | ||
def test_pidof_quiet(adb): | ||
"""adb.pidof() can be called in quiet mode on a process that exists.""" | ||
adb = ADB(mock_tools, "exampleDevice") | ||
adb.run = Mock(return_value="5678\n") | ||
|
||
assert adb.pidof("com.example", quiet=True) == "5678" | ||
adb.run.assert_called_once_with("shell", "pidof", "-s", "com.example", quiet=True) | ||
|
||
|
||
def test_pidof_fail_exit_0(mock_tools): | ||
def test_pidof_fail_exit_0(adb): | ||
"""If adb.pidof() returns a PID of 0, it is interpreted as the process not | ||
existing.""" | ||
adb = ADB(mock_tools, "exampleDevice") | ||
adb.run = Mock(return_value="") | ||
|
||
assert adb.pidof("com.example") is None | ||
adb.run.assert_called_once_with("shell", "pidof", "-s", "com.example") | ||
|
||
|
||
def test_pidof_fail_exit_1(mock_tools): | ||
def test_pidof_fail_exit_1(adb): | ||
"""If adb.pidof() fails, it is interpreted as the process not existing.""" | ||
adb = ADB(mock_tools, "exampleDevice") | ||
adb.run = Mock(side_effect=subprocess.CalledProcessError(1, "adb shell")) | ||
|
||
assert adb.pidof("com.example") is None | ||
adb.run.assert_called_once_with("shell", "pidof", "-s", "com.example") |
Oops, something went wrong.