summaryrefslogtreecommitdiff
path: root/tests/conftest.py
diff options
context:
space:
mode:
authorDavid Luevano Alvarado <david@luevano.xyz>2023-02-21 21:02:23 -0600
committerDavid Luevano Alvarado <david@luevano.xyz>2023-02-21 21:02:23 -0600
commit28c2ae9102d4204b3f0a79419eec1e72dbbc529a (patch)
treee93b4034371bc569f2a528db6cd5ad29afd9b001 /tests/conftest.py
parentf2ab2bac6b26f82730d5f5d7ab1e6d5f2f1060e3 (diff)
add configuration testing, small refactor
Diffstat (limited to 'tests/conftest.py')
-rw-r--r--tests/conftest.py52
1 files changed, 44 insertions, 8 deletions
diff --git a/tests/conftest.py b/tests/conftest.py
index 1beffc6..b44fbf6 100644
--- a/tests/conftest.py
+++ b/tests/conftest.py
@@ -1,31 +1,60 @@
import os
import sys
-from typing import Callable
import pytest
-from logging import getLogger, DEBUG
+from typing import Callable
+from pytest import MonkeyPatch
+from argparse import ArgumentParser
+from datetime import datetime, timezone
+from importlib.metadata import version as v
+from logging import Logger, getLogger, DEBUG
from pyssg.arg_parser import get_parser
from pyssg.custom_logger import setup_logger
-@pytest.fixture
-def test_dir():
- return os.path.dirname(os.path.abspath(__file__))
+@pytest.fixture(scope='session')
+def version():
+ return v('pyssg')
+
+
+@pytest.fixture(scope='session')
+def rss_date_fmt():
+ return '%a, %d %b %Y %H:%M:%S GMT'
+
+
+@pytest.fixture(scope='session')
+def sitemap_date_fmt():
+ return '%Y-%m-%d'
+
+
+@pytest.fixture(scope='session')
+def test_dir() -> str:
+ return str(os.path.dirname(os.path.abspath(__file__)))
+
+
+@pytest.fixture(scope='session')
+def test_resource() -> str:
+ return 'tests.io_files'
@pytest.fixture(scope='session')
-def arg_parser():
+def simple_yaml() -> str:
+ return 'simple.yaml'
+
+
+@pytest.fixture(scope='session')
+def arg_parser() -> ArgumentParser:
return get_parser()
@pytest.fixture(scope='session')
-def logger():
+def logger() -> Logger:
setup_logger(__name__, DEBUG)
return getLogger(__name__)
@pytest.fixture
-def capture_stdout(monkeypatch: Callable) -> dict[str, str | int]:
+def capture_stdout(monkeypatch: MonkeyPatch) -> dict[str, str | int]:
buffer: dict[str, str | int] = {'stdout': '', 'write_calls': 0}
def fake_writer(s):
@@ -34,3 +63,10 @@ def capture_stdout(monkeypatch: Callable) -> dict[str, str | int]:
monkeypatch.setattr(sys.stdout, 'write', fake_writer)
return buffer
+
+
+@pytest.fixture
+def get_fmt_time() -> Callable[..., str]:
+ def fmt_time(fmt: str) -> str:
+ return datetime.now(tz=timezone.utc).strftime(fmt)
+ return fmt_time