From 4a77f0daa1a57143d710a223dbc9ce2654282542 Mon Sep 17 00:00:00 2001 From: Sam Date: Tue, 19 Nov 2024 14:59:52 +1000 Subject: [PATCH] fix linting --- .pre-commit-config.yaml | 2 +- e2e-tests/__init__.py | 0 e2e-tests/conftest.py | 25 +++++++++++++------------ e2e-tests/test_integration.py | 6 +++--- e2e-tests/test_nessus.py | 16 +++------------- 5 files changed, 20 insertions(+), 29 deletions(-) create mode 100644 e2e-tests/__init__.py diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 2480cb16..8408bc92 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -52,6 +52,6 @@ repos: args: - --max-line-length=120 - --min-public-methods=0 - - --good-names=w,q,f,fp,i,e + - --good-names=o,w,q,f,fp,i,e - --disable=E0401,W1201,W1203,C0114,C0115,C0116,C0411,W0107,W0511,W0702,R0801,R1705,R1710 language_version: python3 diff --git a/e2e-tests/__init__.py b/e2e-tests/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/e2e-tests/conftest.py b/e2e-tests/conftest.py index 7fbdf248..0595cc46 100644 --- a/e2e-tests/conftest.py +++ b/e2e-tests/conftest.py @@ -4,7 +4,6 @@ import tempfile import time from functools import partial -from typing import List, Tuple import certifi from kubernetes import client @@ -40,19 +39,21 @@ def wait_until_ready(**kwargs): time.sleep(2) try: pods = corev1.list_namespaced_pod(namespace=NAMESPACE, **kwargs) - if len(pods.items) != 1: - raise RuntimeError(f"Unexpected number of pods {len(pods.items)} matching: {kwargs}") - pod = pods.items[0] - - # Check if pod is ready by looking at conditions - if pod.status.conditions: - for condition in pod.status.conditions: - if condition.type == "Ready": - logging.info(f"{pod.metadata.name} Ready={condition.status}") - if condition.status == "True": - return True except client.ApiException as e: logging.error(f"Error checking pod status: {e}") + return False + + if len(pods.items) != 1: + raise RuntimeError(f"Unexpected number of pods {len(pods.items)} matching: {kwargs}") + pod = pods.items[0] + + # Check if pod is ready by looking at conditions + if pod.status.conditions: + for condition in pod.status.conditions: + if condition.type == "Ready": + logging.info(f"{pod.metadata.name} Ready={condition.status}") + if condition.status == "True": + return True return False diff --git a/e2e-tests/test_integration.py b/e2e-tests/test_integration.py index e8206c0c..5ed027b6 100644 --- a/e2e-tests/test_integration.py +++ b/e2e-tests/test_integration.py @@ -2,9 +2,9 @@ import os import re -from conftest import tee_log -from conftest import TestBase -from conftest import wait_until_ready +from conftest import tee_log # pylint: disable=E0611 +from conftest import TestBase # pylint: disable=E0611 +from conftest import wait_until_ready # pylint: disable=E0611 class TestRapiDAST(TestBase): diff --git a/e2e-tests/test_nessus.py b/e2e-tests/test_nessus.py index f0f623ec..950ab703 100644 --- a/e2e-tests/test_nessus.py +++ b/e2e-tests/test_nessus.py @@ -1,8 +1,8 @@ import os -from conftest import tee_log -from conftest import TestBase -from conftest import wait_until_ready +from conftest import tee_log # pylint: disable=E0611 +from conftest import TestBase # pylint: disable=E0611 +from conftest import wait_until_ready # pylint: disable=E0611 class TestNessus(TestBase): @@ -18,13 +18,3 @@ def test_nessus(self): logfile = os.path.join(self.tempdir, "rapidast-nessus.log") tee_log("rapidast-nessus", logfile) - - # # XXX relies on rapidast-vapi pod cat-ing the result json file after execution - # with open(logfile, "r", encoding="utf-8") as f: - # logs = f.read() - # pattern = r"^{\s*$.*$" - # matches = re.findall(pattern, logs, re.MULTILINE | re.DOTALL) - # assert matches, f"{logfile} did not contain expected json results" - # results = json.loads(matches[0]) - - # assert len(results["site"][0]["alerts"]) == 3