From d7be7cb1b58c9cd07f69caf73cd27cd78325a95a Mon Sep 17 00:00:00 2001 From: SAIKAT KARMAKAR Date: Sat, 6 Jan 2024 21:31:16 +0530 Subject: [PATCH] 6th Jan 2024. Phew...Everything is done. hope to see all gree workflows --- .github/workflows/tests.yml | 6 +++--- pdm.lock | 2 +- pyproject.toml | 8 ++----- tests/integration/test_bee_integration.py | 26 +++++++++++------------ 4 files changed, 19 insertions(+), 23 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 90ff26c..70bc043 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -37,9 +37,9 @@ jobs: - name: Run Black run: pdm run black --check . - - - name: Run isort - run: pdm run isort --check-only . + # Ruff should be enough + # - name: Run isort + # run: pdm run isort --check-only . - name: Run flake8 run: pdm run flake8 . diff --git a/pdm.lock b/pdm.lock index b66a299..bd2eb36 100644 --- a/pdm.lock +++ b/pdm.lock @@ -5,7 +5,7 @@ groups = ["default", "lint", "test"] strategy = ["cross_platform", "inherit_metadata"] lock_version = "4.4.1" -content_hash = "sha256:ac9418075225c6708ed005d2ab2517b0c458d75349996135d72179d5d22dab3a" +content_hash = "sha256:4d5406fb03e12df7e489fd96792c9fb5ab68c123b95a8edc8509f32181656496" [[package]] name = "aiohttp" diff --git a/pyproject.toml b/pyproject.toml index 80503d7..ba0b0d5 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -2,7 +2,7 @@ [project] name = "bee-py" version = "0.1.0" -description = "" +description = "Python client library for connecting to Bee decentralised storage" authors = [ { name = "SAIKAT KARMAKAR", email = "saikickkarma@protonmail.com" }, ] @@ -12,10 +12,9 @@ dependencies = [ "websocket-client>=1.6.4", "eth-pydantic-types>=0.1.0a3", # need for pydantic compatible HexBytes "web3>=6.12.0", - "pydantic>=2.5.2", # TODO: remove this "deepmerge>=1.1.1", "eth-ape>=0.7.0", - "swarm-cid-py>=0.1.2", + "swarm-cid-py>=0.1.3", "ecdsa>=0.18.0", ] requires-python = ">=3.9" @@ -193,8 +192,5 @@ python_files = "test_*.py" testpaths = "tests" markers = "fuzzing: Run Hypothesis fuzz test suite" filterwarnings = [ - #"error", "ignore::DeprecationWarning", - # # note the use of single quote below to denote "raw" strings in TOML - # 'ignore:function ham\(\) is deprecated:DeprecationWarning', ] \ No newline at end of file diff --git a/tests/integration/test_bee_integration.py b/tests/integration/test_bee_integration.py index 2bc4788..2abc272 100644 --- a/tests/integration/test_bee_integration.py +++ b/tests/integration/test_bee_integration.py @@ -1,7 +1,6 @@ import json import random - -# import time +from datetime import datetime, timezone from pathlib import Path import pytest @@ -23,9 +22,9 @@ # * Helper Functions -def random_byte_array(length=100): +def random_byte_array(length=100, seed=500): # * not completely random - random.seed(500) + random.seed(seed) return bytearray(random.randint(0, 255) for _ in range(length)) # noqa: S311 @@ -39,7 +38,7 @@ def sample_file(data: bytes): # * Global Settings for testing -existing_topic = bytes(random_byte_array(32)) +existing_topic = bytes(random_byte_array(32, datetime.now(tz=timezone.utc))) updates: list = [ {"index": "0000000000000000", "reference": bytes([0] * 32)}, { @@ -229,7 +228,7 @@ def test_list_all_pins(bee_class, get_debug_postage): def test_get_pinning_status(bee_class, get_debug_postage): - content = bytes(random_byte_array(16)) + content = bytes(random_byte_array(16, datetime.now(tz=timezone.utc))) result = bee_class.upload_file(get_debug_postage, content, "test", {"pin": False}) with pytest.raises(PinNotFoundError): @@ -262,7 +261,7 @@ def test_pin_unpin_collection_from_directory(bee_class, get_debug_postage, data_ # ? Test stewardship def test_reupload_pinned_data(bee_class, get_debug_postage): - content = bytes(random_byte_array(16)) + content = bytes(random_byte_array(16, datetime.now(tz=timezone.utc))) result = bee_class.upload_file(get_debug_postage, content, "test", {"pin": True}) # * Does not return anything, but will throw exception if something is going wrong @@ -271,10 +270,11 @@ def test_reupload_pinned_data(bee_class, get_debug_postage): @pytest.mark.timeout(ERR_TIMEOUT) def test_if_reference_is_retrievable(bee_class): - # content = bytes(random_byte_array(16)) + # * There is some problem with the bee API suddenly this test stopped working + # content = bytes(random_byte_array(16, datetime.now(tz=timezone.utc))) # result = bee_class.upload_file(get_debug_postage, content, "test", {"pin": True}) - # assert bee_class.is_reference_retrievable(result.reference.value) is True + # assert bee_class.is_reference_retrievable(str(result.reference)) is True # * Reference that has correct form, but should not exist on the network assert ( @@ -291,7 +291,7 @@ def test_if_reference_is_retrievable(bee_class): @pytest.mark.timeout(ERR_TIMEOUT) def test_write_updates_reference_zero(bee_url, get_debug_postage, signer): - topic = bytes(random_byte_array(32)) + topic = bytes(random_byte_array(32, datetime.now(tz=timezone.utc))) bee_class = Bee(bee_url, {"signer": signer}) feed = bee_class.make_feed_writer("sequence", topic, signer) @@ -307,7 +307,7 @@ def test_write_updates_reference_zero(bee_url, get_debug_postage, signer): @pytest.mark.timeout(ERR_TIMEOUT) def test_write_updates_reference_non_zero(bee_url, get_debug_postage, signer): - topic = bytes(random_byte_array(32)) + topic = bytes(random_byte_array(32, datetime.now(tz=timezone.utc))) bee_class = Bee(bee_url, {"signer": signer}) feed = bee_class.make_feed_writer("sequence", topic, signer) @@ -325,7 +325,7 @@ def test_write_updates_reference_non_zero(bee_url, get_debug_postage, signer): @pytest.mark.timeout(ERR_TIMEOUT) def test_fail_fetching_non_existing_index(bee_url, get_debug_postage, signer): - topic = bytes(random_byte_array(32)) + topic = bytes(random_byte_array(32, datetime.now(tz=timezone.utc))) bee_class = Bee(bee_url, {"signer": signer}) feed = bee_class.make_feed_writer("sequence", topic, signer) @@ -344,7 +344,7 @@ def test_fail_fetching_non_existing_index(bee_url, get_debug_postage, signer): @pytest.mark.timeout(ERR_TIMEOUT) def test_create_feeds_manifest_and_retreive_data(bee_url, get_debug_postage, signer, bee_ky_options): - topic = bytes(random_byte_array(32)) + topic = bytes(random_byte_array(32, datetime.now(tz=timezone.utc))) bee_class = Bee(bee_url, {"signer": signer}) owner = signer.address