forked from kevoreilly/CAPEv2
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Log the image name as well as the process ID; added tests. Also, restore the process is_alive check, disabled 4 years ago. Consequently, commented out excessive logging. Credit: @nbargnesi
- Loading branch information
Showing
2 changed files
with
102 additions
and
39 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import unittest | ||
from unittest.mock import MagicMock, patch | ||
|
||
from lib.api.process import Process | ||
|
||
|
||
class ProcessTests(unittest.TestCase): | ||
@patch("lib.api.process.PSAPI", MagicMock(), create=True) | ||
def test_unknown_image_name(self): | ||
process = Process() | ||
assert f"{process}" == "<Process 0 ???>" | ||
|
||
def test_known_image_name(self): | ||
mock_image_name = MagicMock() | ||
mock_image_name.return_value = self.id() | ||
with patch("lib.api.process.Process.get_image_name", mock_image_name): | ||
process = Process() | ||
assert f"{process}" == f"<Process 0 {self.id()}>" |