diff --git a/src/sakia/data/connectors/bma.py b/src/sakia/data/connectors/bma.py index a7e4ab63e3bb84477c8388471f8f993b85663b22..b147cd1c5d6c28ffe519f1ca6450a3ad47c6df2e 100644 --- a/src/sakia/data/connectors/bma.py +++ b/src/sakia/data/connectors/bma.py @@ -89,7 +89,7 @@ def _filter_blockchain_data(request, data): :return: """ include_only = { - bma.wot.lookup: "", + bma.wot.lookup: "/nomatch", bma.tx.history: "/history/[send|received]" } if request in include_only: @@ -122,7 +122,7 @@ class BmaConnector: nb_verification = min(max(1, 0.66*len(synced_nodes)), 10) try: # On chercher des reponses jusqu'a obtenir un nombre de noeuds d'accords de 1 à 66% des noeuds, max 10 - while max([len(ans) for ans in answers.values()] + [0]) <= nb_verification: + while max([len(nodes) for nodes in answers.values()] + [0]) <= nb_verification: node = next(nodes_generator) endpoints = filter_endpoints(request, [node]) tries = 0 diff --git a/src/sakia/money/quantitative.py b/src/sakia/money/quantitative.py index dd9419ed6bec432d1e08661a0f94698430a3d8fc..1f4c06dafa456d362dff65af2883c19a8e3e8bd5 100644 --- a/src/sakia/money/quantitative.py +++ b/src/sakia/money/quantitative.py @@ -94,12 +94,9 @@ class Quantitative(BaseReferential): dividend, base = self._blockchain_processor.last_ud(self.currency) if show_base: localized_value = Quantitative.to_si(value, base) - else: - localized_value = QLocale().toString(float(value), 'f', 2) - - if show_base: prefix = Quantitative.base_str(base) else: + localized_value = QLocale().toString(float(value), 'f', 2) prefix = "" if units or show_base: @@ -116,12 +113,9 @@ class Quantitative(BaseReferential): dividend, base = self._blockchain_processor.last_ud(self.currency) if show_base: localized_value = Quantitative.to_si(value, base) - else: - localized_value = QLocale().toString(float(value), 'f', 2) - - if show_base: prefix = Quantitative.base_str(base) else: + localized_value = QLocale().toString(float(value), 'f', 2) prefix = "" if units or show_base: diff --git a/src/sakia/tests/functional/test_preferences_dialog.py b/src/sakia/tests/functional/test_preferences_dialog.py index 53dc447a5c4e9f3fe81053eb784249731823d39c..e9e69371427dd063cae795b6dab7c202c0df523d 100644 --- a/src/sakia/tests/functional/test_preferences_dialog.py +++ b/src/sakia/tests/functional/test_preferences_dialog.py @@ -11,5 +11,3 @@ def test_preferences_default(application): assert preferences_dialog.checkbox_proxy.isChecked() == application.parameters.enable_proxy assert preferences_dialog.edit_proxy_address.text() == application.parameters.proxy_address assert preferences_dialog.spinbox_proxy_port.value() == application.parameters.proxy_port - assert preferences_dialog.checkbox_international_system.isChecked() == \ - application.parameters.international_system_of_units diff --git a/src/sakia/tests/technical/test_transactions_service.py b/src/sakia/tests/technical/test_transactions_service.py index 60adbe225f40118504014f8b90821becc117683a..47bd10bda8b2e0085b22976ae2a67ced55b7d675 100644 --- a/src/sakia/tests/technical/test_transactions_service.py +++ b/src/sakia/tests/technical/test_transactions_service.py @@ -16,7 +16,7 @@ async def test_send_tx_then_validate(application_with_one_connection, fake_serve fake_server.forge.forge_block() fake_server.forge.forge_block() new_blocks = fake_server.forge.blocks[-3:] - application_with_one_connection.transactions_services[fake_server.forge.currency].handle_new_blocks(new_blocks) + await application_with_one_connection.transactions_services[fake_server.forge.currency].handle_new_blocks(new_blocks) tx_after_parse = application_with_one_connection.transactions_services[fake_server.forge.currency].transfers(bob.key.pubkey) assert tx_after_parse[-1].state is Transaction.VALIDATED await fake_server.close() @@ -31,7 +31,7 @@ async def test_receive_tx(application_with_one_connection, fake_server, bob, ali fake_server.forge.forge_block() fake_server.forge.forge_block() new_blocks = fake_server.forge.blocks[-3:] - application_with_one_connection.transactions_services[fake_server.forge.currency].handle_new_blocks(new_blocks) + await application_with_one_connection.transactions_services[fake_server.forge.currency].handle_new_blocks(new_blocks) tx_after_parse = application_with_one_connection.transactions_services[fake_server.forge.currency].transfers(bob.key.pubkey) assert tx_after_parse[-1].state is Transaction.VALIDATED assert len(tx_before_send) + 1 == len(tx_after_parse) diff --git a/src/sakia/tests/unit/money/test_quantitative.py b/src/sakia/tests/unit/money/test_quantitative.py index bfb1578bc91f29ee92cefeee5d363cb78bcea2ed..8ae1f3e482068eb61b93dc6e595a019f799526f4 100644 --- a/src/sakia/tests/unit/money/test_quantitative.py +++ b/src/sakia/tests/unit/money/test_quantitative.py @@ -32,6 +32,9 @@ def test_localized_no_si(application_with_one_connection, bob): def test_localized_with_si(application_with_one_connection, bob): application_with_one_connection.parameters.digits_after_comma = 6 referential = Quantitative(101010000, bob.currency, application_with_one_connection, None) + blockchain = application_with_one_connection.db.blockchains_repo.get_one(currency=bob.currency) + blockchain.last_ud_base = 3 + application_with_one_connection.db.blockchains_repo.update(blockchain) value = referential.localized(units=True, show_base=True) assert value == "1,010.10 x10³ TC" @@ -46,6 +49,9 @@ def test_localized_no_units_no_si(application_with_one_connection, bob): def test_localized_no_units_with_si(application_with_one_connection, bob): application_with_one_connection.parameters.digits_after_comma = 6 referential = Quantitative(101010000, bob.currency, application_with_one_connection, None) + blockchain = application_with_one_connection.db.blockchains_repo.get_one(currency=bob.currency) + blockchain.last_ud_base = 3 + application_with_one_connection.db.blockchains_repo.update(blockchain) value = referential.localized(units=False, show_base=True) assert value == "1,010.10 x10³" @@ -59,6 +65,10 @@ def test_diff_localized_no_si(application_with_one_connection, bob): def test_diff_localized_with_si(application_with_one_connection, bob): application_with_one_connection.parameters.digits_after_comma = 6 referential = Quantitative(101010000, bob.currency, application_with_one_connection, None) + blockchain = application_with_one_connection.db.blockchains_repo.get_one(currency=bob.currency) + blockchain.last_ud_base = 3 + application_with_one_connection.db.blockchains_repo.update(blockchain) + value = referential.diff_localized(units=True, show_base=True) assert value == "1,010.10 x10³ TC" @@ -69,8 +79,12 @@ def test_diff_localized_no_units_no_si(application_with_one_connection, bob): value = referential.diff_localized(units=False, show_base=False) assert value == "1,010,101.10" + def test_diff_localized_no_units_with_si(application_with_one_connection, bob): application_with_one_connection.parameters.digits_after_comma = 6 referential = Quantitative(10100000000, bob.currency, application_with_one_connection, None) + blockchain = application_with_one_connection.db.blockchains_repo.get_one(currency=bob.currency) + blockchain.last_ud_base = 6 + application_with_one_connection.db.blockchains_repo.update(blockchain) value = referential.diff_localized(units=False, show_base=True) assert value == "101.00 x10â¶" diff --git a/src/sakia/tests/unit/money/test_quantitative_zsum.py b/src/sakia/tests/unit/money/test_quantitative_zsum.py index 7f3931fe504a492959c1af910f2f19f84cdef6c7..2bbe25dc84a5baf65ac626a2bc7d2a5e0e8bcba3 100644 --- a/src/sakia/tests/unit/money/test_quantitative_zsum.py +++ b/src/sakia/tests/unit/money/test_quantitative_zsum.py @@ -32,21 +32,21 @@ def test_localized_no_si(application_with_one_connection, bob): def test_localized_with_si(application_with_one_connection, bob): application_with_one_connection.parameters.digits_after_comma = 6 referential = QuantitativeZSum(110 * 1000, bob.currency, application_with_one_connection, None) - value = referential.localized(units=True, international_system=True) + value = referential.localized(units=True, show_base=True) assert value == "1,088.11 Q0 TC" def test_localized_no_units_no_si(application_with_one_connection, bob): application_with_one_connection.parameters.digits_after_comma = 6 referential = QuantitativeZSum(110, bob.currency, application_with_one_connection, None) - value = referential.localized(units=False, international_system=False) + value = referential.localized(units=False, show_base=False) assert value == "-10.79" def test_localized_no_units_with_si(application_with_one_connection, bob): application_with_one_connection.parameters.digits_after_comma = 6 referential = QuantitativeZSum(110 * 1000, bob.currency, application_with_one_connection, None) - value = referential.localized(units=False, international_system=True) + value = referential.localized(units=False, show_base=True) assert value == "1,088.11 Q0" @@ -59,19 +59,25 @@ def test_diff_localized_no_si(application_with_one_connection, bob): def test_diff_localized_with_si(application_with_one_connection, bob): application_with_one_connection.parameters.digits_after_comma = 6 referential = QuantitativeZSum(101000000, bob.currency, application_with_one_connection, None) - value = referential.diff_localized(units=True, international_system=True) + blockchain = application_with_one_connection.db.blockchains_repo.get_one(currency=bob.currency) + blockchain.last_ud_base = 3 + application_with_one_connection.db.blockchains_repo.update(blockchain) + value = referential.diff_localized(units=True, show_base=True) assert value == "1,010.00 x10³ TC" def test_diff_localized_no_units_no_si(application_with_one_connection, bob): application_with_one_connection.parameters.digits_after_comma = 6 referential = QuantitativeZSum(101010110, bob.currency, application_with_one_connection, None) - value = referential.diff_localized(units=False, international_system=False) + value = referential.diff_localized(units=False, show_base=False) assert value == "1,010,101.10" def test_diff_localized_no_units_with_si(application_with_one_connection, bob): application_with_one_connection.parameters.digits_after_comma = 6 referential = QuantitativeZSum(101000000, bob.currency, application_with_one_connection, None) - value = referential.diff_localized(units=False, international_system=True) + blockchain = application_with_one_connection.db.blockchains_repo.get_one(currency=bob.currency) + blockchain.last_ud_base = 3 + application_with_one_connection.db.blockchains_repo.update(blockchain) + value = referential.diff_localized(units=False, show_base=True) assert value == "1,010.00 x10³" diff --git a/src/sakia/tests/unit/money/test_relative.py b/src/sakia/tests/unit/money/test_relative.py index c012c2e8a85f2e7b876cae072a84b8c334973f31..0bb50bf24fdefbb07b782489eb1a8231c1335c7e 100644 --- a/src/sakia/tests/unit/money/test_relative.py +++ b/src/sakia/tests/unit/money/test_relative.py @@ -34,22 +34,22 @@ def test_localized_no_si(application_with_one_connection, bob): def test_localized_with_si(application_with_one_connection, bob): application_with_one_connection.parameters.digits_after_comma = 6 referential = Relative(1, bob.currency, application_with_one_connection, None) - value = referential.localized(units=True, international_system=True) - assert value == "4.291845 x10â»Â³ UD TC" + value = referential.localized(units=True, show_base=True) + assert value == "0.004292 UD TC" def test_localized_no_units_no_si(application_with_one_connection, bob): application_with_one_connection.parameters.digits_after_comma = 6 referential = Relative(11, bob.currency, application_with_one_connection, None) - value = referential.localized(units=False, international_system=False) + value = referential.localized(units=False, show_base=False) assert value == "0.047210" def test_localized_no_units_with_si(application_with_one_connection, bob): application_with_one_connection.parameters.digits_after_comma = 6 referential = Relative(1, bob.currency, application_with_one_connection, None) - value = referential.localized(units=False, international_system=True) - assert value == "4.291845 x10â»Â³ UD" + value = referential.localized(units=False, show_base=True) + assert value == "0.004292" def test_diff_localized_no_si(application_with_one_connection, bob): @@ -62,19 +62,19 @@ def test_diff_localized_no_si(application_with_one_connection, bob): def test_diff_localized_with_si(application_with_one_connection, bob): application_with_one_connection.parameters.digits_after_comma = 6 referential = Relative(1, bob.currency, application_with_one_connection, None) - value = referential.diff_localized(units=True, international_system=True) + value = referential.diff_localized(units=True, show_base=True) assert value, "9.090909 x10â» UD TC" def test_diff_localized_no_units_no_si(application_with_one_connection, bob): application_with_one_connection.parameters.digits_after_comma = 6 referential = Relative(1, bob.currency, application_with_one_connection, None) - value = referential.diff_localized(units=False, international_system=False) + value = referential.diff_localized(units=False, show_base=False) assert value == "0.004292" def test_diff_localized_no_units_with_si(application_with_one_connection, bob): application_with_one_connection.parameters.digits_after_comma = 6 referential = Relative(1, bob.currency, application_with_one_connection, None) - value = referential.diff_localized(units=False, international_system=True) - assert value == "4.291845 x10â»Â³ UD" + value = referential.diff_localized(units=False, show_base=True) + assert value == "0.004292" diff --git a/src/sakia/tests/unit/money/test_relative_zsum.py b/src/sakia/tests/unit/money/test_relative_zsum.py index 245b679c341de913b31806910106a20d6a28d9b5..e25b410d6bbba7ddb59c4e63507cb3f50ff816cc 100644 --- a/src/sakia/tests/unit/money/test_relative_zsum.py +++ b/src/sakia/tests/unit/money/test_relative_zsum.py @@ -34,7 +34,7 @@ def test_localized_with_si(application_with_one_connection, bob): application_with_one_connection.parameters.digits_after_comma = 6 referential = RelativeZSum(1, bob.currency, application_with_one_connection, None) - value = referential.localized(units=True, international_system=True) + value = referential.localized(units=True, show_base=True) assert value == "-4.040487 R0 TC" @@ -42,7 +42,7 @@ def test_localized_no_units_no_si(application_with_one_connection, bob): application_with_one_connection.parameters.digits_after_comma = 6 referential = RelativeZSum(110, bob.currency, application_with_one_connection, None) - value = referential.localized(units=False, international_system=False) + value = referential.localized(units=False, show_base=False) assert value == "-3.526336" @@ -50,8 +50,8 @@ def test_localized_no_units_with_si(application_with_one_connection, bob): application_with_one_connection.parameters.digits_after_comma = 6 referential = RelativeZSum(1, bob.currency, application_with_one_connection, None) - value = referential.localized(units=False, international_system=True) - assert value == "-4.040487 R0" + value = referential.localized(units=False, show_base=True) + assert value == "-4.040487" def test_diff_localized_no_si(application_with_one_connection, bob): @@ -64,19 +64,19 @@ def test_diff_localized_with_si(application_with_one_connection, bob): application_with_one_connection.parameters.digits_after_comma = 6 referential = RelativeZSum(1, bob.currency, application_with_one_connection, None) - value = referential.diff_localized(units=True, international_system=True) - assert value == "4.291845 x10â»Â³ UD TC" + value = referential.diff_localized(units=True, show_base=True) + assert value == "0.004292 UD TC" def test_diff_localized_no_units_no_si(application_with_one_connection, bob): application_with_one_connection.parameters.digits_after_comma = 6 referential = RelativeZSum(90, bob.currency, application_with_one_connection, None) - value = referential.diff_localized(units=False, international_system=False) + value = referential.diff_localized(units=False, show_base=False) assert value == "0.386266" def test_diff_localized_no_units_with_si(application_with_one_connection, bob): referential = RelativeZSum(90, bob.currency, application_with_one_connection, None) - value = referential.diff_localized(units=False, international_system=True) - assert value == "0.39 UD" + value = referential.diff_localized(units=False, show_base=True) + assert value == "0.39"