Skip to content

Commit

Permalink
unit test fixes
Browse files Browse the repository at this point in the history
Signed-off-by: Andrew Whitehead <[email protected]>
  • Loading branch information
andrewwhitehead committed Nov 13, 2023
1 parent b0116b0 commit af5ebd3
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
3 changes: 3 additions & 0 deletions aries_cloudagent/admin/tests/test_admin_server.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import gc
import json

import pytest
Expand Down Expand Up @@ -501,6 +502,8 @@ def _smaller_scope():
return test_module.AdminResponder(profile, None)

responder = _smaller_scope()
gc.collect() # help ensure collection of profile

with pytest.raises(RuntimeError):
await responder.send_outbound(None)

Expand Down
9 changes: 6 additions & 3 deletions aries_cloudagent/core/in_memory/profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

from ...config.injection_context import InjectionContext
from ...config.provider import ClassProvider
from ...storage.base import BaseStorage
from ...storage.base import BaseStorage, BaseStorageSearch
from ...storage.vc_holder.base import VCHolder
from ...utils.classloader import DeferLoad
from ...wallet.base import BaseWallet
Expand All @@ -28,7 +28,6 @@ class InMemoryProfile(Profile):

def __init__(self, *, context: InjectionContext = None, name: str = None):
"""Create a new InMemoryProfile instance."""
global STORAGE_CLASS, WALLET_CLASS
super().__init__(context=context, name=name, created=True)
self.keys = {}
self.local_dids = {}
Expand All @@ -40,6 +39,8 @@ def bind_providers(self):
"""Initialize the profile-level instance providers."""
injector = self._context.injector

injector.bind_instance(BaseStorageSearch, STORAGE_CLASS(self))

injector.bind_provider(
VCHolder,
ClassProvider(
Expand Down Expand Up @@ -114,7 +115,9 @@ async def _setup(self):

def _init_context(self):
"""Initialize the session context."""
self._context.injector.bind_instance(BaseStorage, STORAGE_CLASS(self.profile))
self._context.injector.bind_instance(
BaseStorage, self.profile.inject(BaseStorageSearch)
)
self._context.injector.bind_instance(BaseWallet, WALLET_CLASS(self.profile))

@property
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ async def test_connection_record_without_mediation_metadata(
with mock.patch.object(
storage,
"find_record",
mock.CoroutineMock(raises=StorageNotFoundError),
mock.CoroutineMock(side_effect=StorageNotFoundError),
) as mock_storage_find_record:
handler_inst = handler.ConnectionRequestHandler()
responder = MockResponder()
Expand Down

0 comments on commit af5ebd3

Please sign in to comment.