Files
basicmachines-co-basic-memory/tests/test_basic_memory.py
T
Paul Hernandez 6da143898b feat: configure logfire telemetry (#12)
Co-authored-by: phernandez <phernandez@basicmachines.co>
2025-02-18 15:53:38 -06:00

48 lines
1.1 KiB
Python

"""Tests for basic-memory package"""
import sys
import tomllib
import pytest
from frontmatter.default_handlers import toml
from basic_memory import __version__
from basic_memory.config import config
def read_toml_version(file_path):
try:
with open(file_path, "rb") as f:
if sys.version_info >= (3, 11):
data = tomllib.load(f)
else:
data = toml.load(f)
if "project" in data and "version" in data["project"]:
return data["project"]["version"]
else:
return None
except FileNotFoundError:
return None
except (toml.TomlDecodeError, tomllib.TOMLDecodeError):
return None
file_path = "pyproject.toml"
version = read_toml_version(file_path)
def test_version():
"""Test version is set in project src code and pyproject.toml"""
assert __version__ == version
def test_config_env():
"""Test the config env is set to test for pytest"""
assert config.env == "test"
@pytest.mark.asyncio
async def test_config_env_async():
"""Test the config env is set to test for async pytest"""
assert config.env == "test"