Skip to content

Commit

Permalink
Add unit tests for the cache.py module
Browse files Browse the repository at this point in the history
Signed-off-by: Mihaela Balutoiu <[email protected]>
  • Loading branch information
mihaelabalutoiu committed Nov 3, 2023
1 parent 64d86bf commit 153bdeb
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions coriolis/tests/test_cache.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Copyright 2023 Cloudbase Solutions Srl
# All Rights Reserved.

from unittest import mock
from coriolis import exception
from coriolis import cache
from coriolis.tests import test_base


class TestGetCacheDecoratorTestCase(test_base.CoriolisBaseTestCase):
"""Collection of tests for the Coriolis cache package."""

@mock.patch.object(cache.cache, 'get_memoization_decorator')
def test_get_cache_decorator(self, mock_get_memoization_decorator):
provider = 'ValidProviderName'
result = cache.get_cache_decorator(provider)

self.assertEqual(result, mock_get_memoization_decorator.return_value)
mock_get_memoization_decorator.assert_called_once_with(
cache.CONF,
cache.cache_region,
provider
)

def test_get_cache_decorator_invalid_provider_name(self):
invalid_providers = [123, '', None]

for provider in invalid_providers:
self.assertRaises(exception.CoriolisException,
cache.get_cache_decorator,
provider)

0 comments on commit 153bdeb

Please sign in to comment.