Skip to content

Commit

Permalink
6th Jan 2024. Phew...Everything is done. hope to see all gree workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
Aviksaikat committed Jan 6, 2024
1 parent bad02f1 commit d7be7cb
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 23 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 .
Expand Down
2 changes: 1 addition & 1 deletion pdm.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 2 additions & 6 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "[email protected]" },
]
Expand All @@ -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"
Expand Down Expand Up @@ -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',
]
26 changes: 13 additions & 13 deletions tests/integration/test_bee_integration.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import json
import random

# import time
from datetime import datetime, timezone
from pathlib import Path

import pytest
Expand All @@ -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


Expand All @@ -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)},
{
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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
Expand All @@ -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 (
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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

Expand Down

0 comments on commit d7be7cb

Please sign in to comment.