Ejemplo n.º 1
0
def test_cache_mixin__from_cache_error(mocker):
    with mocker.patch.object(Team._cache_client, 'mget',
                             mocker.MagicMock(
                                     side_effect=ConnectionError)):
        assert Team._from_cache([1]) == {}

    with mocker.patch.object(Team._cache_client, 'mget',
                             mocker.MagicMock(side_effect=TypeError)):
        assert Team._from_cache([2]) == {}
Ejemplo n.º 2
0
def test_from_cache(mocker):
    t = Team(id=0, team_name='test')
    _key = 0

    with mocker.patch.object(_RedisWrapper, "mget",
                             return_value=t.__rawdata__):
        m = Team._from_cache([_key])
        assert _key in m