mirror of
https://github.com/OpenBB-finance/OpenBB.git
synced 2026-10-28 21:12:16 +00:00
tests for repository/abstract
This commit is contained in:
@@ -0,0 +1,56 @@
|
||||
from typing import Any, List, Optional, Tuple, TypeVar
|
||||
|
||||
from openbb_core.app.repository.abstract.access_token_repository import (
|
||||
AccessTokenRepository,
|
||||
)
|
||||
from pydantic import BaseModel
|
||||
|
||||
T = TypeVar("T", bound=BaseModel)
|
||||
|
||||
|
||||
def test_journal_entry_repository():
|
||||
class TestAccessTokenRepository(AccessTokenRepository):
|
||||
def __init__(self, test_arg_1, test_arg_2):
|
||||
self.test_arg_1 = test_arg_1
|
||||
self.test_arg_2 = test_arg_2
|
||||
super().__init__()
|
||||
|
||||
@property
|
||||
def collection_name(self):
|
||||
return "test_collection"
|
||||
|
||||
def create(self, model):
|
||||
pass
|
||||
|
||||
@property
|
||||
def database_name(self):
|
||||
return "test_database"
|
||||
|
||||
def delete(self, filter_list: Optional[List[Tuple[str, Any]]] = None):
|
||||
pass
|
||||
|
||||
def delete_all(self, filter_list: Optional[List[Tuple[str, Any]]] = None):
|
||||
pass
|
||||
|
||||
def read(
|
||||
self,
|
||||
field_list: Optional[List[str]] = None,
|
||||
filter_list: Optional[List[Tuple[str, Any]]] = None,
|
||||
):
|
||||
pass
|
||||
|
||||
def read_all(
|
||||
self,
|
||||
field_list: Optional[List[str]] = None,
|
||||
filter_list: Optional[List[Tuple[str, Any]]] = None,
|
||||
):
|
||||
pass
|
||||
|
||||
def update(self, model: T):
|
||||
pass
|
||||
|
||||
def mock_method(self):
|
||||
return self.test_arg_1, self.test_arg_2
|
||||
|
||||
jr = TestAccessTokenRepository("xpto_1", "xpto_2")
|
||||
assert isinstance(jr, AccessTokenRepository)
|
||||
@@ -0,0 +1,56 @@
|
||||
from typing import Any, List, Optional, Tuple, TypeVar
|
||||
|
||||
from openbb_core.app.repository.abstract.journal_entry_repository import (
|
||||
JournalEntryRepository,
|
||||
)
|
||||
from pydantic import BaseModel
|
||||
|
||||
T = TypeVar("T", bound=BaseModel)
|
||||
|
||||
|
||||
def test_journal_entry_repository():
|
||||
class TestJournalEntryRepository(JournalEntryRepository):
|
||||
def __init__(self, test_arg_1, test_arg_2):
|
||||
self.test_arg_1 = test_arg_1
|
||||
self.test_arg_2 = test_arg_2
|
||||
super().__init__()
|
||||
|
||||
@property
|
||||
def collection_name(self):
|
||||
return "test_collection"
|
||||
|
||||
def create(self, model):
|
||||
pass
|
||||
|
||||
@property
|
||||
def database_name(self):
|
||||
return "test_database"
|
||||
|
||||
def delete(self, filter_list: Optional[List[Tuple[str, Any]]] = None):
|
||||
pass
|
||||
|
||||
def delete_all(self, filter_list: Optional[List[Tuple[str, Any]]] = None):
|
||||
pass
|
||||
|
||||
def read(
|
||||
self,
|
||||
field_list: Optional[List[str]] = None,
|
||||
filter_list: Optional[List[Tuple[str, Any]]] = None,
|
||||
):
|
||||
pass
|
||||
|
||||
def read_all(
|
||||
self,
|
||||
field_list: Optional[List[str]] = None,
|
||||
filter_list: Optional[List[Tuple[str, Any]]] = None,
|
||||
):
|
||||
pass
|
||||
|
||||
def update(self, model: T):
|
||||
pass
|
||||
|
||||
def mock_method(self):
|
||||
return self.test_arg_1, self.test_arg_2
|
||||
|
||||
jr = TestJournalEntryRepository("xpto_1", "xpto_2")
|
||||
assert isinstance(jr, JournalEntryRepository)
|
||||
@@ -0,0 +1,56 @@
|
||||
from typing import Any, List, Optional, Tuple, TypeVar
|
||||
|
||||
from openbb_core.app.repository.abstract.journal_repository import (
|
||||
JournalRepository,
|
||||
)
|
||||
from pydantic import BaseModel
|
||||
|
||||
T = TypeVar("T", bound=BaseModel)
|
||||
|
||||
|
||||
def test_journal_repository():
|
||||
class TestJournalRepository(JournalRepository):
|
||||
def __init__(self, test_arg_1, test_arg_2):
|
||||
self.test_arg_1 = test_arg_1
|
||||
self.test_arg_2 = test_arg_2
|
||||
super().__init__()
|
||||
|
||||
@property
|
||||
def collection_name(self):
|
||||
return "test_collection"
|
||||
|
||||
def create(self, model):
|
||||
pass
|
||||
|
||||
@property
|
||||
def database_name(self):
|
||||
return "test_database"
|
||||
|
||||
def delete(self, filter_list: Optional[List[Tuple[str, Any]]] = None):
|
||||
pass
|
||||
|
||||
def delete_all(self, filter_list: Optional[List[Tuple[str, Any]]] = None):
|
||||
pass
|
||||
|
||||
def read(
|
||||
self,
|
||||
field_list: Optional[List[str]] = None,
|
||||
filter_list: Optional[List[Tuple[str, Any]]] = None,
|
||||
):
|
||||
pass
|
||||
|
||||
def read_all(
|
||||
self,
|
||||
field_list: Optional[List[str]] = None,
|
||||
filter_list: Optional[List[Tuple[str, Any]]] = None,
|
||||
):
|
||||
pass
|
||||
|
||||
def update(self, model: T):
|
||||
pass
|
||||
|
||||
def mock_method(self):
|
||||
return self.test_arg_1, self.test_arg_2
|
||||
|
||||
jr = TestJournalRepository("xpto_1", "xpto_2")
|
||||
assert isinstance(jr, JournalRepository)
|
||||
@@ -0,0 +1,56 @@
|
||||
from typing import Any, List, Optional, Tuple, TypeVar
|
||||
|
||||
from openbb_core.app.repository.abstract.repository import (
|
||||
Repository,
|
||||
)
|
||||
from pydantic import BaseModel
|
||||
|
||||
T = TypeVar("T", bound=BaseModel)
|
||||
|
||||
|
||||
def test_repository():
|
||||
class TestRepository(Repository):
|
||||
def __init__(self, test_arg_1, test_arg_2):
|
||||
self.test_arg_1 = test_arg_1
|
||||
self.test_arg_2 = test_arg_2
|
||||
super().__init__()
|
||||
|
||||
@property
|
||||
def collection_name(self):
|
||||
return "test_collection"
|
||||
|
||||
def create(self, model):
|
||||
pass
|
||||
|
||||
@property
|
||||
def database_name(self):
|
||||
return "test_database"
|
||||
|
||||
def delete(self, filter_list: Optional[List[Tuple[str, Any]]] = None):
|
||||
pass
|
||||
|
||||
def delete_all(self, filter_list: Optional[List[Tuple[str, Any]]] = None):
|
||||
pass
|
||||
|
||||
def read(
|
||||
self,
|
||||
field_list: Optional[List[str]] = None,
|
||||
filter_list: Optional[List[Tuple[str, Any]]] = None,
|
||||
):
|
||||
pass
|
||||
|
||||
def read_all(
|
||||
self,
|
||||
field_list: Optional[List[str]] = None,
|
||||
filter_list: Optional[List[Tuple[str, Any]]] = None,
|
||||
):
|
||||
pass
|
||||
|
||||
def update(self, model: T):
|
||||
pass
|
||||
|
||||
def mock_method(self):
|
||||
return self.test_arg_1, self.test_arg_2
|
||||
|
||||
jr = TestRepository("xpto_1", "xpto_2")
|
||||
assert isinstance(jr, Repository)
|
||||
@@ -0,0 +1,63 @@
|
||||
from typing import Any, List, Optional, Tuple, TypeVar
|
||||
|
||||
from openbb_core.app.repository.abstract.user_settings_repository import (
|
||||
UserSettingsRepository,
|
||||
)
|
||||
from pydantic import BaseModel
|
||||
|
||||
T = TypeVar("T", bound=BaseModel)
|
||||
|
||||
|
||||
def test_journal_entry_repository():
|
||||
class TestUserSettingsRepository(UserSettingsRepository):
|
||||
def __init__(self, test_arg_1, test_arg_2):
|
||||
self.test_arg_1 = test_arg_1
|
||||
self.test_arg_2 = test_arg_2
|
||||
super().__init__()
|
||||
|
||||
@property
|
||||
def collection_name(self):
|
||||
return "test_collection"
|
||||
|
||||
def create(self, model):
|
||||
pass
|
||||
|
||||
@property
|
||||
def database_name(self):
|
||||
return "test_database"
|
||||
|
||||
def delete(self, filter_list: Optional[List[Tuple[str, Any]]] = None):
|
||||
pass
|
||||
|
||||
def delete_all(self, filter_list: Optional[List[Tuple[str, Any]]] = None):
|
||||
pass
|
||||
|
||||
def read(
|
||||
self,
|
||||
field_list: Optional[List[str]] = None,
|
||||
filter_list: Optional[List[Tuple[str, Any]]] = None,
|
||||
):
|
||||
pass
|
||||
|
||||
def read_all(
|
||||
self,
|
||||
field_list: Optional[List[str]] = None,
|
||||
filter_list: Optional[List[Tuple[str, Any]]] = None,
|
||||
):
|
||||
pass
|
||||
|
||||
def update(self, model: T):
|
||||
pass
|
||||
|
||||
def mock_method(self):
|
||||
return self.test_arg_1, self.test_arg_2
|
||||
|
||||
def read_by_profile(
|
||||
self,
|
||||
field_list: Optional[List[str]] = None,
|
||||
filter_list: Optional[List[Tuple[str, Any]]] = None,
|
||||
):
|
||||
pass
|
||||
|
||||
jr = TestUserSettingsRepository("xpto_1", "xpto_2")
|
||||
assert isinstance(jr, UserSettingsRepository)
|
||||
@@ -0,0 +1,19 @@
|
||||
from unittest.mock import patch
|
||||
|
||||
from openbb_core.app.repository.mongodb.access_token_repository import (
|
||||
AccessTokenRepository,
|
||||
)
|
||||
|
||||
|
||||
@patch("openbb_core.app.repository.mongodb.access_token_repository.MongoClient")
|
||||
def test_access_token_repository(mock_mongo_client):
|
||||
atr = AccessTokenRepository(
|
||||
client=mock_mongo_client,
|
||||
collection_name="collection_name",
|
||||
database_name="database_name",
|
||||
)
|
||||
|
||||
assert isinstance(atr, AccessTokenRepository)
|
||||
assert atr.client == mock_mongo_client
|
||||
assert atr.collection_name == "collection_name"
|
||||
assert atr.database_name == "database_name"
|
||||
Reference in New Issue
Block a user