mirror of
https://github.com/Security-Onion-Solutions/securityonion.git
synced 2025-12-10 03:02:58 +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
|
name: python-test
|
||||||
|
|
||||||
on:
|
on: [push, pull_request]
|
||||||
push:
|
|
||||||
branches: [ $default-branch ]
|
|
||||||
pull_request:
|
|
||||||
branches: [ $default-branch ]
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
@@ -13,7 +9,8 @@ jobs:
|
|||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
python-version: ["3.8", "3.9", "3.10"]
|
python-version: ["3.10"]
|
||||||
|
python-code-path: ["salt/sensoroni/files/analyzers"]
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
@@ -24,14 +21,11 @@ jobs:
|
|||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: |
|
run: |
|
||||||
python -m pip install --upgrade pip
|
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
|
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
|
||||||
- name: Lint with flake8
|
- name: Lint with flake8
|
||||||
run: |
|
run: |
|
||||||
# stop the build if there are Python syntax errors or undefined names
|
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
|
||||||
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
|
|
||||||
- name: Test with pytest
|
- name: Test with pytest
|
||||||
run: |
|
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():
|
def main():
|
||||||
print('{"result":{ "requestId": "something-generated-by-whois", "someother_field": "more data" }, "summary": "botsrv.btc-goblin.ru"}')
|
print('{"result":{ "requestId": "something-generated-by-whois", "someother_field": "more data" }, "summary": "botsrv.btc-goblin.ru"}')
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
main()
|
main()
|
||||||
|
|||||||
@@ -3,10 +3,11 @@ from unittest.mock import patch
|
|||||||
from whois import whois
|
from whois import whois
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
|
|
||||||
class TestWhoisMethods(unittest.TestCase):
|
class TestWhoisMethods(unittest.TestCase):
|
||||||
|
|
||||||
def test_main(self):
|
def test_main(self):
|
||||||
with patch('sys.stdout', new = StringIO()) as mock_stdout:
|
with patch('sys.stdout', new=StringIO()) as mock_stdout:
|
||||||
whois.main()
|
whois.main()
|
||||||
expected = '{"result":{ "requestId": "something-generated-by-whois", "someother_field": "more data" }, "summary": "botsrv.btc-goblin.ru"}\n'
|
expected = '{"result":{ "requestId": "something-generated-by-whois", "someother_field": "more data" }, "summary": "botsrv.btc-goblin.ru"}\n'
|
||||||
self.assertEqual(mock_stdout.getvalue(), expected)
|
self.assertEqual(mock_stdout.getvalue(), expected)
|
||||||
|
|||||||
Reference in New Issue
Block a user