mirror of
https://github.com/Security-Onion-Solutions/securityonion.git
synced 2025-12-07 17:52:46 +01:00
Analyzer CI
This commit is contained in:
18
.github/workflows/pythontest.yml
vendored
18
.github/workflows/pythontest.yml
vendored
@@ -1,10 +1,6 @@
|
||||
name: python-test
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ $default-branch ]
|
||||
pull_request:
|
||||
branches: [ $default-branch ]
|
||||
on: [push, pull_request]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
@@ -13,7 +9,8 @@ jobs:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
python-version: ["3.8", "3.9", "3.10"]
|
||||
python-version: ["3.10"]
|
||||
python-code-path: ["salt/sensoroni/files/analyzers"]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
@@ -24,14 +21,11 @@ jobs:
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
python -m pip install --upgrade pip
|
||||
python -m pip install flake8 pytest
|
||||
python -m pip install flake8 pytest pytest-cov
|
||||
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
|
||||
- name: Lint with flake8
|
||||
run: |
|
||||
# stop the build if there are Python syntax errors or undefined names
|
||||
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
|
||||
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
|
||||
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
|
||||
flake8 ${{ matrix.python-code-path }} --count --select=E9,E501,F63,F7,F82,W191,W292 --show-source --max-complexity=10 --max-line-length=200 --statistics --doctests
|
||||
- name: Test with pytest
|
||||
run: |
|
||||
pytest
|
||||
pytest ${{ matrix.python-code-path }} --cov=${{ matrix.python-code-path }} --doctest-modules --cov-report=term --cov-fail-under=90 --cov-config=${{ matrix.python-code-path }}/pytest.ini
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
def main():
|
||||
print('{"result":{ "requestId": "something-generated-by-whois", "someother_field": "more data" }, "summary": "botsrv.btc-goblin.ru"}')
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -3,10 +3,11 @@ from unittest.mock import patch
|
||||
from whois import whois
|
||||
import unittest
|
||||
|
||||
|
||||
class TestWhoisMethods(unittest.TestCase):
|
||||
|
||||
def test_main(self):
|
||||
with patch('sys.stdout', new = StringIO()) as mock_stdout:
|
||||
with patch('sys.stdout', new=StringIO()) as mock_stdout:
|
||||
whois.main()
|
||||
expected = '{"result":{ "requestId": "something-generated-by-whois", "someother_field": "more data" }, "summary": "botsrv.btc-goblin.ru"}\n'
|
||||
self.assertEqual(mock_stdout.getvalue(), expected)
|
||||
|
||||
Reference in New Issue
Block a user