mirror of
https://github.com/Security-Onion-Solutions/securityonion.git
synced 2025-12-06 17:22:49 +01:00
more coverage
This commit is contained in:
4
.github/workflows/pythontest.yml
vendored
4
.github/workflows/pythontest.yml
vendored
@@ -4,9 +4,11 @@ on:
|
|||||||
push:
|
push:
|
||||||
paths:
|
paths:
|
||||||
- "salt/sensoroni/files/analyzers/**"
|
- "salt/sensoroni/files/analyzers/**"
|
||||||
|
- "salt/manager/tools/sbin"
|
||||||
pull_request:
|
pull_request:
|
||||||
paths:
|
paths:
|
||||||
- "salt/sensoroni/files/analyzers/**"
|
- "salt/sensoroni/files/analyzers/**"
|
||||||
|
- "salt/manager/tools/sbin"
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
@@ -16,7 +18,7 @@ jobs:
|
|||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
python-version: ["3.10"]
|
python-version: ["3.10"]
|
||||||
python-code-path: ["salt/sensoroni/files/analyzers"]
|
python-code-path: ["salt/sensoroni/files/analyzers", "salt/manager/tools/sbin"]
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
|
|||||||
@@ -85,10 +85,8 @@ def main():
|
|||||||
cmd = commands.get(args[0], showUsage)
|
cmd = commands.get(args[0], showUsage)
|
||||||
code = cmd(args[1:])
|
code = cmd(args[1:])
|
||||||
finally:
|
finally:
|
||||||
try:
|
if os.path.exists(lockFile):
|
||||||
os.remove(lockFile)
|
os.remove(lockFile)
|
||||||
except Exception:
|
|
||||||
print("Lock file (" + lockFile + ") already removed")
|
|
||||||
|
|
||||||
sys.exit(code)
|
sys.exit(code)
|
||||||
|
|
||||||
|
|||||||
@@ -21,6 +21,19 @@ class TestRemove(unittest.TestCase):
|
|||||||
sysmock.assert_called_once_with(1)
|
sysmock.assert_called_once_with(1)
|
||||||
self.assertIn(mock_stdout.getvalue(), "Usage:")
|
self.assertIn(mock_stdout.getvalue(), "Usage:")
|
||||||
|
|
||||||
|
def test_main_help_locked(self):
|
||||||
|
filename = "/tmp/so-yaml.lock"
|
||||||
|
file = open(filename, "w")
|
||||||
|
file.write = "fake lock file"
|
||||||
|
with patch('sys.exit', new=MagicMock()) as sysmock:
|
||||||
|
with patch('sys.stderr', new=StringIO()) as mock_stdout:
|
||||||
|
with patch('time.sleep', new=MagicMock()) as mock_sleep:
|
||||||
|
sys.argv = ["cmd", "help"]
|
||||||
|
soyaml.main()
|
||||||
|
sysmock.assert_called()
|
||||||
|
mock_sleep.assert_called_with(2)
|
||||||
|
self.assertIn(mock_stdout.getvalue(), "Usage:")
|
||||||
|
|
||||||
def test_main_help(self):
|
def test_main_help(self):
|
||||||
with patch('sys.exit', new=MagicMock()) as sysmock:
|
with patch('sys.exit', new=MagicMock()) as sysmock:
|
||||||
with patch('sys.stderr', new=StringIO()) as mock_stdout:
|
with patch('sys.stderr', new=StringIO()) as mock_stdout:
|
||||||
|
|||||||
Reference in New Issue
Block a user