renamed Modles to DataAccessor

Signed-off-by: Jürgen Eckel <juergen@riddleandcode.com>
This commit is contained in:
Jürgen Eckel 2023-03-01 16:21:45 +01:00
parent 50d1276e29
commit c34b8d9164
No known key found for this signature in database
5 changed files with 10 additions and 10 deletions

View File

@ -25,7 +25,7 @@ from transactions.types.elections.validator_utils import election_id_to_public_k
from planetmint.abci.utils import encode_validator, new_validator_set, key_from_base64, public_key_to_base64
from planetmint.application.basevalidationrules import BaseValidationRules
from planetmint.backend.models.output import Output
from planetmint.model.models import Models
from planetmint.model.dataaccessor import DataAccessor
from planetmint.config import Config
from planetmint.config_utils import load_validation_plugin
@ -35,7 +35,7 @@ logger = logging.getLogger(__name__)
class Validator:
def __init__(self, async_io: bool = False):
self.async_io = async_io
self.models = Models(async_io=async_io)
self.models = DataAccessor(async_io=async_io)
self.validation = Validator._get_validation_method()
@staticmethod

View File

@ -19,7 +19,7 @@ from planetmint.backend.models.metadata import MetaData
from planetmint.backend.models.dbtransaction import DbTransaction
class Models:
class DataAccessor:
def __init__(self, database_connection=None, async_io: bool = False):
config_utils.autoconfigure()
self.connection = database_connection if database_connection is not None else Connection(async_io=async_io)

View File

@ -250,9 +250,9 @@ def abci_fixture():
@pytest.fixture
def test_models():
from planetmint.model.models import Models
from planetmint.model.dataaccessor import DataAccessor
return Models()
return DataAccessor()
@pytest.fixture

View File

@ -18,7 +18,7 @@ def test_get_outputs_endpoint(client, user_pk):
m = MagicMock()
m.txid = "a"
m.output = 0
with patch("planetmint.model.models.Models.get_outputs_filtered") as gof:
with patch("planetmint.model.dataaccessor.DataAccessor.get_outputs_filtered") as gof:
gof.return_value = [m, m]
res = client.get(OUTPUTS_ENDPOINT + "?public_key={}".format(user_pk))
assert res.json == [{"transaction_id": "a", "output_index": 0}, {"transaction_id": "a", "output_index": 0}]
@ -30,7 +30,7 @@ def test_get_outputs_endpoint_unspent(client, user_pk):
m = MagicMock()
m.txid = "a"
m.output = 0
with patch("planetmint.model.models.Models.get_outputs_filtered") as gof:
with patch("planetmint.model.dataaccessor.DataAccessor.get_outputs_filtered") as gof:
gof.return_value = [m]
params = "?spent=False&public_key={}".format(user_pk)
res = client.get(OUTPUTS_ENDPOINT + params)
@ -45,7 +45,7 @@ def test_get_outputs_endpoint_spent(client, user_pk):
m = MagicMock()
m.txid = "a"
m.output = 0
with patch("planetmint.model.models.Models.get_outputs_filtered") as gof:
with patch("planetmint.model.dataaccessor.DataAccessor.get_outputs_filtered") as gof:
gof.return_value = [m]
params = "?spent=true&public_key={}".format(user_pk)
res = client.get(OUTPUTS_ENDPOINT + params)

View File

@ -404,7 +404,7 @@ def test_transactions_get_list_good(client):
asset_ids = ["1" * 64]
with patch("planetmint.model.models.Models.get_transactions_filtered", get_txs_patched):
with patch("planetmint.model.dataaccessor.DataAccessor.get_transactions_filtered", get_txs_patched):
url = TX_ENDPOINT + "?asset_ids=" + ",".join(asset_ids)
assert client.get(url).json == [
["asset_ids", asset_ids],
@ -430,7 +430,7 @@ def test_transactions_get_list_bad(client):
assert False
with patch(
"planetmint.model.models.Models.get_transactions_filtered",
"planetmint.model.dataaccessor.DataAccessor.get_transactions_filtered",
lambda *_, **__: should_not_be_called(),
):
# Test asset id validated