from unittest.mock import AsyncMock import pytest import pytest_asyncio from src.backend.connectors.db import db class TestClient: _class = db.Client @pytest_asyncio.fixture async def instance(self): instance = self._class() instance.db = AsyncMock() yield instance @pytest.mark.asyncio @pytest.mark.parametrize( "value,expected_type", [ (None, type(None)), (1, str), (["1"], str), (1.0, str), ("1", str), (True, str), (False, str), ({"1": 1}, str), ], ) async def test_audit_meta_set_types(self, instance, value, expected_type): """Test that audit_meta_set accepts different types, but that value is included in the query either as a string or None. """ await instance.Meta.set(1, {"mock_key": value}) assert instance.db.execute_query_nofetch.called assert isinstance( instance.db.execute_query_nofetch.call_args[0][1][2], expected_type )