Skip to content

Commit 9843f45

Browse files
committed
initial integration and schema tests
1 parent bc776e6 commit 9843f45

File tree

8 files changed

+1290
-177
lines changed

8 files changed

+1290
-177
lines changed

.github/workflows/dev.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: dev
2+
on:
3+
workflow_dispatch:
4+
push:
5+
paths:
6+
- bin/**
7+
- glrd/**
8+
- tests/**
9+
- poetry.lock
10+
- pyproject.toml
11+
jobs:
12+
test:
13+
name: test
14+
runs-on: "ubuntu-latest"
15+
defaults:
16+
run:
17+
shell: bash
18+
steps:
19+
- uses: actions/checkout@v4
20+
- name: Install Poetry
21+
uses: snok/install-poetry@v1
22+
- name: Set up Python
23+
uses: actions/setup-python@v5
24+
with:
25+
python-version: 3.13
26+
- name: Install GLRD and dependencies
27+
run: poetry install --with dev
28+
- name: Run linter
29+
run: make lint
30+
- name: Run tests
31+
run: make test

.github/workflows/image-dev.yml

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@ on:
33
workflow_dispatch:
44
push:
55
tags-ignore:
6-
- 'v[0-9]+.[0-9]+.[0-9]+'
6+
- "v[0-9]+.[0-9]+.[0-9]+"
77
paths:
88
- bin/**
99
- glrd/**
10+
- tests/**
1011
- Containerfile
1112
- poetry.lock
1213
- pyproject.toml
@@ -20,7 +21,7 @@ jobs:
2021
strategy:
2122
fail-fast: false
2223
matrix:
23-
arch: [ amd64, arm64 ]
24+
arch: [amd64, arm64]
2425
steps:
2526
- uses: actions/checkout@v4
2627
with:
@@ -41,10 +42,10 @@ jobs:
4142
name: build-${{ matrix.arch }}
4243
path: /tmp/${{ matrix.arch }}-oci.tar
4344
if-no-files-found: error
44-
retention-days: 1
45+
retention-days: 1
4546
push:
4647
name: push
47-
runs-on: 'ubuntu-latest'
48+
runs-on: "ubuntu-latest"
4849
defaults:
4950
run:
5051
shell: bash
@@ -56,12 +57,12 @@ jobs:
5657
uses: actions/download-artifact@v4
5758
with:
5859
name: build-amd64
59-
path: /tmp
60+
path: /tmp
6061
- name: download build-arm64
6162
uses: actions/download-artifact@v4
6263
with:
6364
name: build-arm64
64-
path: /tmp
65+
path: /tmp
6566
- name: podman login
6667
run: |
6768
podman login -u token -p ${{ github.token }} ghcr.io

poetry.lock

Lines changed: 441 additions & 169 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ readme = "README.md"
1111
packages = [{include = "glrd"}]
1212

1313
[tool.poetry.dependencies]
14-
python = "^3.10"
14+
python = "^3.13"
1515
poetry-dynamic-versioning = "*"
1616
boto3 = "*"
1717
deepdiff = "*"
@@ -21,7 +21,14 @@ pytz = "*"
2121
python-dateutil = "*"
2222
requests = "*"
2323
tabulate = "*"
24-
python-gardenlinux-lib = { git = "https://github.com/gardenlinux/python-gardenlinux-lib.git", branch = "main" }
24+
python-gardenlinux-lib = { git = "https://github.com/gardenlinux/python-gardenlinux-lib.git", branch = "0.6.0" }
25+
26+
[tool.poetry.group.dev.dependencies]
27+
pytest = "*"
28+
pytest-cov = "*"
29+
black = "*"
30+
flake8 = "*"
31+
2532

2633
[tool.poetry-dynamic-versioning]
2734
enable = true
@@ -43,3 +50,19 @@ glrd = "glrd.query:main"
4350
[build-system]
4451
requires = ["poetry-core>=1.0.0", "poetry-dynamic-versioning>=1.0.0,<2.0.0"]
4552
build-backend = "poetry_dynamic_versioning.backend"
53+
54+
[tool.pytest.ini_options]
55+
testpaths = ["tests"]
56+
python_files = ["test_*.py"]
57+
python_classes = ["Test*"]
58+
python_functions = ["test_*"]
59+
addopts = [
60+
"-v",
61+
"--tb=short",
62+
"--strict-markers",
63+
"--disable-warnings",
64+
]
65+
markers = [
66+
"integration: marks tests as integration tests",
67+
"unit: marks tests as unit tests",
68+
]

tests/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Tests package for GLRD

tests/conftest.py

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
"""
2+
Pytest configuration and fixtures for GLRD tests.
3+
"""
4+
5+
import os
6+
import tempfile
7+
import shutil
8+
import pytest
9+
from pathlib import Path
10+
11+
12+
@pytest.fixture
13+
def test_dir():
14+
"""Create a temporary directory for test files."""
15+
test_dir = tempfile.mkdtemp(prefix='glrd_test_')
16+
yield test_dir
17+
# Cleanup
18+
if os.path.exists(test_dir):
19+
shutil.rmtree(test_dir)
20+
21+
22+
@pytest.fixture
23+
def manage_script():
24+
"""Path to the manage.py script."""
25+
script_path = Path(__file__).parent.parent / "glrd" / "manage.py"
26+
assert script_path.exists(), f"manage.py not found at {script_path}"
27+
return str(script_path)
28+
29+
30+
@pytest.fixture
31+
def query_script():
32+
"""Path to the query.py script."""
33+
script_path = Path(__file__).parent.parent / "glrd" / "query.py"
34+
assert script_path.exists(), f"query.py not found at {script_path}"
35+
return str(script_path)
36+
37+
38+
@pytest.fixture
39+
def glrd_script():
40+
"""Path to the glrd script (query.py)."""
41+
script_path = Path(__file__).parent.parent / "glrd" / "query.py"
42+
assert script_path.exists(), f"query.py not found at {script_path}"
43+
return str(script_path)

0 commit comments

Comments
 (0)