import json from unittest.mock import AsyncMock import pytest from src.backend.connectors.db.components import users class TestUsers: _class = users.Users @pytest.fixture def instance(self): mock_client = AsyncMock() return self._class(mock_client) def test_init(self, instance): assert instance.client is not None def test_parse_scopes(self, instance): mock_scopes = json.dumps( { "scope1": "level1", "scope2": instance._null_placeholder, instance._null_placeholder: "level3", } ) users = [{"scopes": mock_scopes}] result = instance._parse_scopes([*users]) assert result[0]["scopes"] == {"scope1": "level1"}, ( "Should remove any item which has " "either key or value as null placeholder." )