Skip to content

Commit

Permalink
Update and modify files for the project
Browse files Browse the repository at this point in the history
- Added new files:
  - tests/integration/test_bee_integration.py
- Updated files:
  - pyproject.toml
  - src/bee_py/bee.py
  - src/bee_py/modules/chunk.py
  - tests/conftest.py
  • Loading branch information
Aviksaikat committed Dec 18, 2023
1 parent bdbea1a commit 49869ec
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 11 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ lint = [
# black formatter
[tool.black]
line-length = 120
target-version = ['py39', 'py310', 'py311', 'py312']
target-version = ['py39', 'py310', 'py311']
include = '\.pyi?$'

# isort
Expand Down
2 changes: 1 addition & 1 deletion src/bee_py/bee.py
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ def upload_chunk(
msg = f"Chunk must have a maximum size of {CHUNK_SIZE} bytes. Received chunk size: {len(data)}"
raise BeeArgumentError(msg, data)

if options is not None:
if options:
assert_upload_options(options)

return chunk_api.upload(
Expand Down
3 changes: 0 additions & 3 deletions src/bee_py/modules/chunk.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@
ENDPOINT = "chunks"


# TODO: there is an issue with the upload function of chunk. tests are sutck


def upload(
request_options: BeeRequestOptions,
data: bytes,
Expand Down
17 changes: 11 additions & 6 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def max_int() -> int:


@pytest.fixture(scope="session", autouse=True)
def get_api_url():
def bee_api_url():
if os.path.isfile(ENV_FILE):
with open(ENV_FILE) as f:
data = json.loads(f.read())
Expand All @@ -44,7 +44,7 @@ def get_api_url():


@pytest.fixture(scope="session", autouse=True)
def get_peer_api_url():
def bee_peer_api_url():
if os.path.isfile(ENV_FILE):
with open(ENV_FILE) as f:
data = json.loads(f.read())
Expand Down Expand Up @@ -88,13 +88,13 @@ def get_data_folder() -> Path:


@pytest.fixture
def bee_url(get_api_url) -> str:
return get_api_url
def bee_url(bee_api_url) -> str:
return bee_api_url


@pytest.fixture
def bee_peer_url(get_peer_api_url) -> str:
return get_peer_api_url
def bee_peer_url(bee_peer_api_url) -> str:
return bee_peer_api_url


@pytest.fixture
Expand Down Expand Up @@ -413,3 +413,8 @@ def bee_signer(runner, ape_cli):
)

assert result.exit_code == 0, result.output


@pytest.fixture
def bee_class(bee_url) -> Bee:
return Bee(bee_url)
37 changes: 37 additions & 0 deletions tests/integration/test_bee_integration.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# from unittest.mock import MagicMock, patch

# import pydantic
import pytest

from bee_py.bee import Bee
from bee_py.feed.topic import make_topic_from_string
from bee_py.feed.type import FeedType
from bee_py.types.type import (
CHUNK_SIZE,
REFERENCE_HEX_LENGTH,
SPAN_SIZE,
BatchId,
BeeRequestOptions,
CollectionUploadOptions,
PssMessageHandler,
ReferenceResponse,
UploadOptions,
)
from bee_py.utils.error import BeeArgumentError, BeeError

# * Global variables


def test_strip_trailing_slash():
bee = Bee("http://127.0.0.1:1633/")

assert bee.url == "http://127.0.0.1:1633"


def test_upload_and_downalod_chunk(bee_class, get_debug_postage):
content = bytes(bytearray(100))

referece = bee_class.upload_chunk(get_debug_postage, content)
downloaded_chunk = bee_class.download_chunk(referece)

assert downloaded_chunk == content

0 comments on commit 49869ec

Please sign in to comment.