Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 0 additions & 18 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,21 +39,3 @@ jobs:

- name: run tests
run: poetry run pytest

smoke:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: 3.14

- name: install poetry
run: pip install poetry

- name: install dependencies
run: poetry install --with dev

- name: run tests
run: poetry run yatl ./smoke
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,6 @@ ENV/
.DS_Store
Thumbs.db
dist/
PUBLISH_GUIDE.md
PUBLISH_GUIDE.md

.coverage
14 changes: 13 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,18 @@ typing: ## Run typing checks
smoke: ## Run E2E checks
poetry run yatl ./smoke

.PHONY: unit_tests
.PHONY: test-unit
unit_tests: ## Run unit tests with pytest
poetry run pytest

.PHONY: coverage
coverage: ## Run unit tests with coverage
poetry run pytest --cov=yatl --cov-report=term-missing
coverage combine

.PHONY: test
test: ## Run all tests
poetry run ruff check --select I --fix .
poetry run ruff format .
poetry run ruff check .
poetry run pytest
140 changes: 132 additions & 8 deletions poetry.lock

Large diffs are not rendered by default.

14 changes: 13 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ requests = ">=2.32.5"
jinja2 = ">=3.1.6"
pyyaml = ">=6.0.3"
lxml = ">=6.0.2"
pytest-cov = "^7.1.0"

[tool.poetry.group.dev]
optional = true
Expand All @@ -38,9 +39,20 @@ Documentation = "https://github.com/Khabib73/YATL#readme"
Repository = "https://github.com/Khabib73/YATL"
Issues = "https://github.com/Khabib73/YATL/issues"

[tool.coverage.run]
source = ["src/yatl"]
concurrency = ["multiprocessing"]
parallel = true

[tool.coverage.report]
exclude_lines = [
"pragma: no cover",
"if __name__ == .__main__.:",
]

[build-system]
requires = ["poetry-core>=2.0.0,<3.0.0"]
build-backend = "poetry.core.masonry.api"

[tool.ruff.lint]
select = ["N", "UP", "I"]
select = ["N", "UP", "I"]
Empty file removed smoke/__init__.py
Empty file.
19 changes: 0 additions & 19 deletions smoke/codeforces.yatl.yaml

This file was deleted.

15 changes: 13 additions & 2 deletions src/yatl/utils/file_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,25 @@ def load_test_yaml(file_path: str) -> dict[str, str | int | list[Any]] | bool:


def search_files(base_path: str) -> list[str]:
"""Recursively searches for test files with a .yatl.yaml/.yatl.yml suffix.
"""Searches for test files with a .yatl.yaml/.yatl.yml suffix.

If base_path is a single file with a valid extension, returns it directly.
Otherwise, recursively searches the directory for matching files.

Args:
base_path: Base directory for the search.
base_path: Path to a .yatl.yaml/.yatl.yml file or a directory.

Returns:
List of found file paths.

Raises:
DirectoryNotFoundError: If base_path is neither a file nor a directory.
"""
if os.path.isfile(base_path):
if base_path.endswith(".yatl.yaml") or base_path.endswith(".yatl.yml"):
return [base_path]
return []

if not os.path.isdir(base_path):
raise DirectoryNotFoundError(f"Directory does not exist: {base_path}")

Expand Down
13 changes: 13 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
from collections.abc import Callable
from pathlib import PurePath

import pytest

from src.yatl.extractor import DataExtractor
Expand Down Expand Up @@ -39,3 +42,13 @@ def data():
},
],
}


@pytest.fixture
def fixture_path() -> Callable[[str], str]:
"""Returns path to the fixture."""

def factory(path: str) -> str:
return str(PurePath(__file__).parent.joinpath("fixtures", path))

return factory
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
base_url: https://jsonplaceholder.typicode.com

steps:

- name: create_post
request:
method: POST
Expand Down
File renamed without changes.
9 changes: 9 additions & 0 deletions tests/fixtures/ping.yatl.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
name: Hello Google
base_url: https://google.com

steps:
- name: ping
request:
method: GET
expect:
status_code: 200
10 changes: 10 additions & 0 deletions tests/fixtures/skip_test.yatl.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
name: Hello Google
base_url: https://google.com
skip: True

steps:
- name: ping
request:
method: GET
expect:
status_code: 200
85 changes: 85 additions & 0 deletions tests/test_cli/test_command.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
import os
import subprocess
import sys


def test_ping(fixture_path):
env = os.environ.copy()
env["COVERAGE_PROCESS_START"] = "pyproject.toml"

result = subprocess.run(
[sys.executable, "-m", "yatl", fixture_path("ping.yatl.yaml")],
capture_output=True,
text=True,
env=env,
)

assert result.returncode == 0, (
f"yatl exited with code {result.returncode}\n"
f"stdout: {result.stdout}\n"
f"stderr: {result.stderr}"
)
assert not result.stderr, f"stderr should be empty, got: {result.stderr}"
assert "Test passed" in result.stdout, (
f"Expected 'Test passed' in stdout, got:\n{result.stdout}"
)


def test_params(fixture_path):
env = os.environ.copy()
env["COVERAGE_PROCESS_START"] = "pyproject.toml"

result = subprocess.run(
[sys.executable, "-m", "yatl", fixture_path("params.yatl.yaml")],
capture_output=True,
text=True,
env=env,
)

assert result.returncode == 0, (
f"yatl exited with code {result.returncode}\n"
f"stdout: {result.stdout}\n"
f"stderr: {result.stderr}"
)
assert not result.stderr, f"stderr should be empty, got: {result.stderr}"
assert "Test passed" in result.stdout, (
f"Expected 'Test passed' in stdout, got:\n{result.stdout}"
)


def test_json(fixture_path):
env = os.environ.copy()
env["COVERAGE_PROCESS_START"] = "pyproject.toml"

result = subprocess.run(
[sys.executable, "-m", "yatl", fixture_path("params.yatl.yaml")],
capture_output=True,
text=True,
env=env,
)

assert result.returncode == 0, (
f"yatl exited with code {result.returncode}\n"
f"stdout: {result.stdout}\n"
f"stderr: {result.stderr}"
)
assert not result.stderr, f"stderr should be empty, got: {result.stderr}"
assert "Test passed" in result.stdout, (
f"Expected 'Test passed' in stdout, got:\n{result.stdout}"
)


def test_skip(fixture_path):
env = os.environ.copy()
env["COVERAGE_PROCESS_START"] = "pyproject.toml"

result = subprocess.run(
[sys.executable, "-m", "yatl", fixture_path("skip_test.yatl.yaml")],
capture_output=True,
text=True,
env=env,
)

assert result.returncode == 0, (
f"yatl exited with code {result.returncode}\nstdout: {result.stdout}\n"
)
Loading