From 985546839dff83951253b713089b316f5082f47b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrgen=20Eckel?= Date: Mon, 26 Sep 2022 21:01:13 +0200 Subject: [PATCH] blackified and added an additional test MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jürgen Eckel --- planetmint/backend/tarantool/connection.py | 12 ++++---- tests/web/test_outputs.py | 33 ++++++++++++++++++++-- 2 files changed, 36 insertions(+), 9 deletions(-) diff --git a/planetmint/backend/tarantool/connection.py b/planetmint/backend/tarantool/connection.py index b459f83..93e260e 100644 --- a/planetmint/backend/tarantool/connection.py +++ b/planetmint/backend/tarantool/connection.py @@ -68,7 +68,7 @@ class TarantoolDBConnection(DBConnection): def close(self): try: - if self.__conn: + if self.__conn: self.__conn.close() self.__conn = None except Exception as exc: @@ -84,7 +84,7 @@ class TarantoolDBConnection(DBConnection): def exec(self, query, only_data=True): try: conn = self.connect() - conn.execute( query ) if only_data else conn.execute(query) + conn.execute(query) if only_data else conn.execute(query) except tarantool.error.OperationalError as op_error: raise op_error except tarantool.error.NetworkError as net_error: @@ -109,12 +109,12 @@ class TarantoolDBConnection(DBConnection): def run_command(self, command: str, config: dict): from subprocess import run - + try: self.close() except ConnectionError: pass - + print(f" commands: {command}") host_port = "%s:%s" % (self.host, self.port) execute_cmd = self._file_content_to_bytes(path=command) @@ -128,12 +128,12 @@ class TarantoolDBConnection(DBConnection): def run_command_with_output(self, command: str): from subprocess import run - + try: self.close() except ConnectionError: pass - + host_port = "%s:%s" % ( Config().get()["database"]["host"], Config().get()["database"]["port"], diff --git a/tests/web/test_outputs.py b/tests/web/test_outputs.py index 6a88699..6aa22e4 100644 --- a/tests/web/test_outputs.py +++ b/tests/web/test_outputs.py @@ -11,7 +11,6 @@ from planetmint.transactions.types.assets.create import Create from planetmint.transactions.types.assets.transfer import Transfer - OUTPUTS_ENDPOINT = "/api/v1/outputs/" @@ -83,12 +82,40 @@ def test_get_outputs_endpoint_with_invalid_spent(client, user_pk): assert res.status_code == 400 -@pytest.mark.skip +@pytest.mark.skip( + reason="just failing sometimes - a test to narrow down the issues of the test 'test_get_divisble_transactions_returns_500'" +) +@pytest.mark.abci +def test_get_divisble_transactions_returns_500_phase_one(b, client): + import json + import time + + TX_ENDPOINT = "/api/v1/transactions" + + def mine(tx_list): + b.store_bulk_transactions(tx_list) + + alice_priv, alice_pub = crypto.generate_key_pair() + # bob_priv, bob_pub = crypto.generate_key_pair() + # carly_priv, carly_pub = crypto.generate_key_pair() + # time.sleep(1) + create_tx = Create.generate([alice_pub], [([alice_pub], 4)]) + create_tx.sign([alice_priv]) + # ATTENTION: comment out the next line and the test will never fail + res = client.post(TX_ENDPOINT, data=json.dumps(create_tx.to_dict())) + assert res.status_code == 202 + + mine([create_tx]) + + +@pytest.mark.skip( + reason="this test fails with strange inconsistent tarantool error messages. sometimes, it's even passing." +) @pytest.mark.abci def test_get_divisble_transactions_returns_500(b, client): import json import time - + TX_ENDPOINT = "/api/v1/transactions" def mine(tx_list):