Skip to content

Commit

Permalink
Conditionally run test_edr_positions
Browse files Browse the repository at this point in the history
  • Loading branch information
ways committed Sep 26, 2024
1 parent faeca5a commit 2e46a1c
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 14 deletions.
2 changes: 2 additions & 0 deletions .bandit
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
[bandit]
# B101: assert_used
skips = B101

exclude = test_init.py
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ RUN apt-get update && \
# Set workdir
WORKDIR /app

COPY requirements.txt ./
COPY requirements.txt pytest.ini ./
COPY sedr/ ./sedr/
RUN python3 -m venv ./venv && \
./venv/bin/pip install -r /app/requirements.txt
Expand Down
4 changes: 4 additions & 0 deletions pytest.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[pytest]
filterwarnings =
ignore::DeprecationWarning
ignore::pytest.PytestAssertRewriteWarning
22 changes: 19 additions & 3 deletions sedr/test_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,34 @@
import subprocess
import sys


class TestInit(unittest.TestCase):

def test_version(self):
result = subprocess.run([sys.executable, "./__init__.py", "--version"], capture_output=True, text=True)
result = subprocess.run(
[sys.executable, "./__init__.py", "--version"],
capture_output=True,
text=True,
)
self.assertIn("v", result.stdout)

def test_help(self):
result = subprocess.run([sys.executable, "./__init__.py", "--help"], capture_output=True, text=True)
result = subprocess.run(
[sys.executable, "./__init__.py", "--help"], capture_output=True, text=True
)
self.assertIn("usage:", result.stdout)

def test_run(self):
result = subprocess.run([sys.executable, "./__init__.py", "--url", "https://edrisobaric.k8s.met.no"], capture_output=True, text=True)
result = subprocess.run(
[
sys.executable,
"./__init__.py",
"--url",
"https://edrisobaric.k8s.met.no",
],
capture_output=True,
text=True,
)
self.assertEqual(0, result.returncode)


Expand Down
13 changes: 4 additions & 9 deletions sedr/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
__license__ = "GPL-3.0"
edr_version = "1.1"

args = logger = None


def parse_args(version: str = "") -> argparse.Namespace:
"""Parse arguments."""
Expand All @@ -29,8 +31,8 @@ def parse_args(version: str = "") -> argparse.Namespace:
parser.add_argument(
"--iterations",
type=int,
default=50,
help="Amount of examples to generate, per test. Default 50. Increase for local, developer testing.",
default=10,
help="Amount of examples to generate, per test. Default 10. Increase for local, developer testing.",
)
parser.add_argument(
"--log-file",
Expand Down Expand Up @@ -174,10 +176,3 @@ def locate_openapi_url(url: str) -> str:
# Yaml
# Xml
return ""


args = logger = None

if __name__ == "__main__":
args = parse_args()
logger = set_up_logging(args=args, logfile=args.log_file)
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[tox]
envlist = unittest, py{310,312}, black, prospector, bandit
envlist = unittest, black, prospector, bandit, py312

# Tell tox to not require a setup.py file
skipsdist = True
Expand Down

0 comments on commit 2e46a1c

Please sign in to comment.