blackified with newest verion to satisfy CI

Signed-off-by: Jürgen Eckel <juergen@riddleandcode.com>
This commit is contained in:
Jürgen Eckel 2023-02-14 22:43:33 +01:00
parent a23c180a0b
commit 3afb2e6f3d
No known key found for this signature in database
16 changed files with 5 additions and 33 deletions

View File

@ -67,6 +67,7 @@ skipped_naughty_strings = [
naughty_strings = [naughty for naughty in naughty_strings if naughty not in skipped_naughty_strings] naughty_strings = [naughty for naughty in naughty_strings if naughty not in skipped_naughty_strings]
# This is our base test case, but we'll reuse it to send naughty strings as both keys and values. # This is our base test case, but we'll reuse it to send naughty strings as both keys and values.
def send_naughty_tx(assets, metadata): def send_naughty_tx(assets, metadata):
# ## Set up a connection to Planetmint # ## Set up a connection to Planetmint
@ -118,7 +119,6 @@ def send_naughty_tx(assets, metadata):
@pytest.mark.parametrize("naughty_string", naughty_strings, ids=naughty_strings) @pytest.mark.parametrize("naughty_string", naughty_strings, ids=naughty_strings)
def test_naughty_keys(naughty_string): def test_naughty_keys(naughty_string):
assets = [{"data": multihash(marshal({naughty_string: "nice_value"}))}] assets = [{"data": multihash(marshal({naughty_string: "nice_value"}))}]
metadata = multihash(marshal({naughty_string: "nice_value"})) metadata = multihash(marshal({naughty_string: "nice_value"}))
@ -127,7 +127,6 @@ def test_naughty_keys(naughty_string):
@pytest.mark.parametrize("naughty_string", naughty_strings, ids=naughty_strings) @pytest.mark.parametrize("naughty_string", naughty_strings, ids=naughty_strings)
def test_naughty_values(naughty_string): def test_naughty_values(naughty_string):
assets = [{"data": multihash(marshal({"nice_key": naughty_string}))}] assets = [{"data": multihash(marshal({"nice_key": naughty_string}))}]
metadata = multihash(marshal({"nice_key": naughty_string})) metadata = multihash(marshal({"nice_key": naughty_string}))

View File

@ -19,7 +19,6 @@ def test_zenroom_signing(
zenroom_script_input, zenroom_script_input,
condition_script_zencode, condition_script_zencode,
): ):
biolabs = generate_keypair() biolabs = generate_keypair()
version = "2.0" version = "2.0"
@ -47,7 +46,6 @@ def test_zenroom_signing(
zenroom_house_assets, zenroom_house_assets,
condition_script_zencode, condition_script_zencode,
): ):
biolabs = generate_keypair() biolabs = generate_keypair()
version = "2.0" version = "2.0"

View File

@ -115,7 +115,6 @@ def send_naughty_tx(assets, metadata):
@pytest.mark.parametrize("naughty_string", naughty_strings, ids=naughty_strings) @pytest.mark.parametrize("naughty_string", naughty_strings, ids=naughty_strings)
def test_naughty_keys(naughty_string): def test_naughty_keys(naughty_string):
assets = [{"data": {naughty_string: "nice_value"}}] assets = [{"data": {naughty_string: "nice_value"}}]
metadata = {naughty_string: "nice_value"} metadata = {naughty_string: "nice_value"}
@ -124,7 +123,6 @@ def test_naughty_keys(naughty_string):
@pytest.mark.parametrize("naughty_string", naughty_strings, ids=naughty_strings) @pytest.mark.parametrize("naughty_string", naughty_strings, ids=naughty_strings)
def test_naughty_values(naughty_string): def test_naughty_values(naughty_string):
assets = [{"data": {"nice_key": naughty_string}}] assets = [{"data": {"nice_key": naughty_string}}]
metadata = {"nice_key": naughty_string} metadata = {"nice_key": naughty_string}

View File

@ -17,7 +17,6 @@ def test_zenroom_signing(
zenroom_script_input, zenroom_script_input,
condition_script_zencode, condition_script_zencode,
): ):
biolabs = generate_keypair() biolabs = generate_keypair()
version = "2.0" version = "2.0"

View File

@ -102,7 +102,6 @@ def store_block(conn, block):
@register_query(LocalMongoDBConnection) @register_query(LocalMongoDBConnection)
def get_txids_filtered(conn, asset_ids, operation=None, last_tx=None): def get_txids_filtered(conn, asset_ids, operation=None, last_tx=None):
match = { match = {
Transaction.CREATE: {"operation": "CREATE", "id": {"$in": asset_ids}}, Transaction.CREATE: {"operation": "CREATE", "id": {"$in": asset_ids}},
Transaction.TRANSFER: {"operation": "TRANSFER", "asset.id": {"$in": asset_ids}}, Transaction.TRANSFER: {"operation": "TRANSFER", "asset.id": {"$in": asset_ids}},

View File

@ -47,7 +47,6 @@ class TransactionDecompose:
} }
def get_map(self, dictionary: dict = None): def get_map(self, dictionary: dict = None):
return ( return (
_save_keys_order(dictionary=dictionary) _save_keys_order(dictionary=dictionary)
if dictionary is not None if dictionary is not None
@ -75,7 +74,6 @@ class TransactionDecompose:
_inputs = [] _inputs = []
input_index = 0 input_index = 0
for _input in self._transaction["inputs"]: for _input in self._transaction["inputs"]:
_inputs.append( _inputs.append(
( (
self._transaction["id"], self._transaction["id"],

View File

@ -18,9 +18,9 @@ from planetmint.web.views import (
def add_routes(app): def add_routes(app):
"""Add the routes to an app""" """Add the routes to an app"""
for (prefix, routes) in API_SECTIONS: for prefix, routes in API_SECTIONS:
api = Api(app, prefix=prefix) api = Api(app, prefix=prefix)
for ((pattern, resource, *args), kwargs) in routes: for (pattern, resource, *args), kwargs in routes:
kwargs.setdefault("strict_slashes", False) kwargs.setdefault("strict_slashes", False)
api.add_resource(resource, pattern, *args, **kwargs) api.add_resource(resource, pattern, *args, **kwargs)

View File

@ -94,7 +94,7 @@ dev_require = ["ipdb", "ipython", "watchdog", "logging_tree", "pre-commit", "twi
tests_require = [ tests_require = [
"coverage", "coverage",
"pep8", "pep8",
"black", "black>=23.1.0",
"hypothesis>=5.3.0", "hypothesis>=5.3.0",
"pytest>=3.0.0", "pytest>=3.0.0",
"pytest-cov==2.8.1", "pytest-cov==2.8.1",

View File

@ -34,7 +34,6 @@ def test_single_in_single_own_single_out_single_own_create(alice, user_pk, b):
# Multiple outputs # Multiple outputs
# Single owners_after per output # Single owners_after per output
def test_single_in_single_own_multiple_out_single_own_create(alice, user_pk, b): def test_single_in_single_own_multiple_out_single_own_create(alice, user_pk, b):
tx = Create.generate( tx = Create.generate(
[alice.public_key], [alice.public_key],
[([user_pk], 50), ([user_pk], 50)], [([user_pk], 50), ([user_pk], 50)],
@ -55,7 +54,6 @@ def test_single_in_single_own_multiple_out_single_own_create(alice, user_pk, b):
# Single output # Single output
# Multiple owners_after # Multiple owners_after
def test_single_in_single_own_single_out_multiple_own_create(alice, user_pk, b): def test_single_in_single_own_single_out_multiple_own_create(alice, user_pk, b):
tx = Create.generate( tx = Create.generate(
[alice.public_key], [alice.public_key],
[([user_pk, user_pk], 100)], [([user_pk, user_pk], 100)],
@ -81,7 +79,6 @@ def test_single_in_single_own_single_out_multiple_own_create(alice, user_pk, b):
# Mix: one output with a single owners_after, one output with multiple # Mix: one output with a single owners_after, one output with multiple
# owners_after # owners_after
def test_single_in_single_own_multiple_out_mix_own_create(alice, user_pk, b): def test_single_in_single_own_multiple_out_mix_own_create(alice, user_pk, b):
tx = Create.generate( tx = Create.generate(
[alice.public_key], [alice.public_key],
[([user_pk], 50), ([user_pk, user_pk], 50)], [([user_pk], 50), ([user_pk, user_pk], 50)],
@ -130,7 +127,6 @@ def test_single_in_multiple_own_single_out_single_own_create(alice, b, user_pk,
# Single output # Single output
# Single owners_after # Single owners_after
def test_single_in_single_own_single_out_single_own_transfer(alice, b, user_pk, user_sk): def test_single_in_single_own_single_out_single_own_transfer(alice, b, user_pk, user_sk):
# CREATE divisible asset # CREATE divisible asset
tx_create = Create.generate( tx_create = Create.generate(
[alice.public_key], [([user_pk], 100)], assets=[{"data": "QmaozNR7DZHQK1ZcU9p7QdrshMvXqWK6gpu5rmrkPdT3L4"}] [alice.public_key], [([user_pk], 100)], assets=[{"data": "QmaozNR7DZHQK1ZcU9p7QdrshMvXqWK6gpu5rmrkPdT3L4"}]
@ -155,7 +151,6 @@ def test_single_in_single_own_single_out_single_own_transfer(alice, b, user_pk,
# Multiple output # Multiple output
# Single owners_after # Single owners_after
def test_single_in_single_own_multiple_out_single_own_transfer(alice, b, user_pk, user_sk): def test_single_in_single_own_multiple_out_single_own_transfer(alice, b, user_pk, user_sk):
# CREATE divisible asset # CREATE divisible asset
tx_create = Create.generate( tx_create = Create.generate(
[alice.public_key], [([user_pk], 100)], assets=[{"data": "QmaozNR7DZHQK1ZcU9p7QdrshMvXqWK6gpu5rmrkPdT3L4"}] [alice.public_key], [([user_pk], 100)], assets=[{"data": "QmaozNR7DZHQK1ZcU9p7QdrshMvXqWK6gpu5rmrkPdT3L4"}]
@ -183,7 +178,6 @@ def test_single_in_single_own_multiple_out_single_own_transfer(alice, b, user_pk
# Single output # Single output
# Multiple owners_after # Multiple owners_after
def test_single_in_single_own_single_out_multiple_own_transfer(alice, b, user_pk, user_sk): def test_single_in_single_own_single_out_multiple_own_transfer(alice, b, user_pk, user_sk):
# CREATE divisible asset # CREATE divisible asset
tx_create = Create.generate( tx_create = Create.generate(
[alice.public_key], [([user_pk], 100)], assets=[{"data": "QmaozNR7DZHQK1ZcU9p7QdrshMvXqWK6gpu5rmrkPdT3L4"}] [alice.public_key], [([user_pk], 100)], assets=[{"data": "QmaozNR7DZHQK1ZcU9p7QdrshMvXqWK6gpu5rmrkPdT3L4"}]
@ -219,7 +213,6 @@ def test_single_in_single_own_single_out_multiple_own_transfer(alice, b, user_pk
# Mix: one output with a single owners_after, one output with multiple # Mix: one output with a single owners_after, one output with multiple
# owners_after # owners_after
def test_single_in_single_own_multiple_out_mix_own_transfer(alice, b, user_pk, user_sk): def test_single_in_single_own_multiple_out_mix_own_transfer(alice, b, user_pk, user_sk):
# CREATE divisible asset # CREATE divisible asset
tx_create = Create.generate( tx_create = Create.generate(
[alice.public_key], [([user_pk], 100)], assets=[{"data": "QmaozNR7DZHQK1ZcU9p7QdrshMvXqWK6gpu5rmrkPdT3L4"}] [alice.public_key], [([user_pk], 100)], assets=[{"data": "QmaozNR7DZHQK1ZcU9p7QdrshMvXqWK6gpu5rmrkPdT3L4"}]
@ -448,7 +441,6 @@ def test_muiltiple_in_mix_own_multiple_out_mix_own_transfer(alice, b, user_pk, u
# Single output # Single output
# Single owners_after # Single owners_after
def test_multiple_in_different_transactions(alice, b, user_pk, user_sk): def test_multiple_in_different_transactions(alice, b, user_pk, user_sk):
# CREATE divisible asset # CREATE divisible asset
# `b` creates a divisible asset and assigns 50 shares to `b` and # `b` creates a divisible asset and assigns 50 shares to `b` and
# 50 shares to `user_pk` # 50 shares to `user_pk`
@ -549,7 +541,6 @@ def test_threshold_same_public_key(alice, b, user_pk, user_sk):
def test_sum_amount(alice, b, user_pk, user_sk): def test_sum_amount(alice, b, user_pk, user_sk):
# CREATE divisible asset with 3 outputs with amount 1 # CREATE divisible asset with 3 outputs with amount 1
tx_create = Create.generate( tx_create = Create.generate(
[alice.public_key], [alice.public_key],
@ -575,7 +566,6 @@ def test_sum_amount(alice, b, user_pk, user_sk):
def test_divide(alice, b, user_pk, user_sk): def test_divide(alice, b, user_pk, user_sk):
# CREATE divisible asset with 1 output with amount 3 # CREATE divisible asset with 1 output with amount 3
tx_create = Create.generate( tx_create = Create.generate(
[alice.public_key], [([user_pk], 3)], assets=[{"data": "QmaozNR7DZHQK1ZcU9p7QdrshMvXqWK6gpu5rmrkPdT3L4"}] [alice.public_key], [([user_pk], 3)], assets=[{"data": "QmaozNR7DZHQK1ZcU9p7QdrshMvXqWK6gpu5rmrkPdT3L4"}]

View File

@ -52,7 +52,6 @@ metadata = {"units": 300, "type": "KG"}
def test_zenroom_signing(): def test_zenroom_signing():
biolabs = generate_key_pair() biolabs = generate_key_pair()
version = "3.0" version = "3.0"

View File

@ -99,7 +99,6 @@ class TestBigchainApi(object):
b.validate_transaction(tx) b.validate_transaction(tx)
def test_write_transaction(self, b, user_sk, user_pk, alice, create_tx): def test_write_transaction(self, b, user_sk, user_pk, alice, create_tx):
asset1 = {"data": "QmaozNR7DZHQK1ZcU9p7QdrshMvXqWK6gpu5rmrkPdT3L4"} asset1 = {"data": "QmaozNR7DZHQK1ZcU9p7QdrshMvXqWK6gpu5rmrkPdT3L4"}
tx = Create.generate([alice.public_key], [([alice.public_key], 1)], assets=[asset1]).sign([alice.private_key]) tx = Create.generate([alice.public_key], [([alice.public_key], 1)], assets=[asset1]).sign([alice.private_key])

View File

@ -315,7 +315,6 @@ def test_write_config():
), ),
) )
def test_database_envs(env_name, env_value, config_key, monkeypatch): def test_database_envs(env_name, env_value, config_key, monkeypatch):
monkeypatch.setattr("os.environ", {env_name: env_value}) monkeypatch.setattr("os.environ", {env_name: env_value})
planetmint.config_utils.autoconfigure() planetmint.config_utils.autoconfigure()

View File

@ -155,7 +155,6 @@ def test_valid_election_votes_received(b_mock, valid_upsert_validator_election,
@pytest.mark.bdb @pytest.mark.bdb
def test_valid_election_conclude(b_mock, valid_upsert_validator_election, ed25519_node_keys): def test_valid_election_conclude(b_mock, valid_upsert_validator_election, ed25519_node_keys):
# Node 0: cast vote # Node 0: cast vote
tx_vote0 = gen_vote(valid_upsert_validator_election, 0, ed25519_node_keys) tx_vote0 = gen_vote(valid_upsert_validator_election, 0, ed25519_node_keys)
@ -214,7 +213,6 @@ def test_valid_election_conclude(b_mock, valid_upsert_validator_election, ed2551
@pytest.mark.abci @pytest.mark.abci
def test_upsert_validator(b, node_key, node_keys, ed25519_node_keys): def test_upsert_validator(b, node_key, node_keys, ed25519_node_keys):
if b.get_latest_block()["height"] == 0: if b.get_latest_block()["height"] == 0:
generate_block(b) generate_block(b)
@ -343,6 +341,6 @@ def test_get_validator_update(b, node_keys, node_key, ed25519_node_keys):
def reset_validator_set(b, node_keys, height): def reset_validator_set(b, node_keys, height):
validators = [] validators = []
for (node_pub, _) in node_keys.items(): for node_pub, _ in node_keys.items():
validators.append({"public_key": {"type": "ed25519-base64", "value": node_pub}, "voting_power": 10}) validators.append({"public_key": {"type": "ed25519-base64", "value": node_pub}, "voting_power": 10})
b.store_validator_set(height, validators) b.store_validator_set(height, validators)

View File

@ -24,7 +24,6 @@ def test_get_assets_with_missing_text_search(client):
@pytest.mark.bdb @pytest.mark.bdb
def test_get_assets_tendermint(client, b, alice): def test_get_assets_tendermint(client, b, alice):
# test returns empty list when no assets are found # test returns empty list when no assets are found
res = client.get(ASSETS_ENDPOINT + "?search=abc") res = client.get(ASSETS_ENDPOINT + "?search=abc")
assert res.json == [] assert res.json == []
@ -45,7 +44,6 @@ def test_get_assets_tendermint(client, b, alice):
@pytest.mark.bdb @pytest.mark.bdb
def test_get_assets_limit_tendermint(client, b, alice): def test_get_assets_limit_tendermint(client, b, alice):
# create two assets # create two assets
assets1 = [{"data": multihash(marshal({"msg": "abc 1"}))}] assets1 = [{"data": multihash(marshal({"msg": "abc 1"}))}]
assets2 = [{"data": multihash(marshal({"msg": "abc 2"}))}] assets2 = [{"data": multihash(marshal({"msg": "abc 2"}))}]

View File

@ -48,7 +48,6 @@ def test_get_metadata_tendermint(client, b, alice):
@pytest.mark.bdb @pytest.mark.bdb
def test_get_metadata_limit_tendermint(client, b, alice): def test_get_metadata_limit_tendermint(client, b, alice):
# create two assets # create two assets
assets1 = [{"data": multihash(marshal({"msg": "abc 1"}))}] assets1 = [{"data": multihash(marshal({"msg": "abc 1"}))}]
meta1 = multihash(marshal({"key": "meta 1"})) meta1 = multihash(marshal({"key": "meta 1"}))

View File

@ -327,7 +327,6 @@ def test_post_invalid_transaction(
@pytest.mark.abci @pytest.mark.abci
def test_post_transfer_transaction_endpoint(client, user_pk, user_sk, posted_create_tx): def test_post_transfer_transaction_endpoint(client, user_pk, user_sk, posted_create_tx):
transfer_tx = Transfer.generate(posted_create_tx.to_inputs(), [([user_pk], 1)], asset_ids=[posted_create_tx.id]) transfer_tx = Transfer.generate(posted_create_tx.to_inputs(), [([user_pk], 1)], asset_ids=[posted_create_tx.id])
transfer_tx = transfer_tx.sign([user_sk]) transfer_tx = transfer_tx.sign([user_sk])