mirror of
https://github.com/planetmint/planetmint.git
synced 2025-03-30 15:08:31 +00:00
renamed Modles to DataAccessor
Signed-off-by: Jürgen Eckel <juergen@riddleandcode.com>
This commit is contained in:
parent
50d1276e29
commit
c34b8d9164
@ -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
|
||||
|
@ -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)
|
@ -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
|
||||
|
@ -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)
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user