Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update IPv8 pointer and tests #8346

Merged
merged 4 commits into from
Dec 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/ruff.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ jobs:
uses: tj-actions/changed-files@v42
with:
files: |
*.py
**/*.py
src/*.py
src/**/*.py
- name: Run ruff
if: steps.changed-py-files.outputs.any_changed == 'true'
run: ruff check ${{ steps.changed-py-files.outputs.all_changed_files }} --force-exclude
3 changes: 2 additions & 1 deletion .ruff.toml
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ exclude = [
"build",
"dist",
"node_modules",
"pyipv8",
"src/tribler/ui",
"venv",
]
Expand All @@ -91,7 +92,7 @@ line-length = 120
# Allow unused variables when underscore-prefixed.
lint.dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$"

target-version = "py37"
target-version = "py39"

[lint.pylint]
max-args = 6
Expand Down
2 changes: 1 addition & 1 deletion pyipv8
Submodule pyipv8 updated 131 files
13 changes: 1 addition & 12 deletions src/tribler/test_integration/test_anon_download.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
from tribler.core.notifier import Notifier
from tribler.core.socks5.server import Socks5Server
from tribler.core.tunnel.community import TriblerTunnelCommunity, TriblerTunnelSettings
from tribler.tribler_config import TriblerConfigManager
from tribler.test_unit.mocks import MockTriblerConfigManager

if TYPE_CHECKING:
from tribler.core.libtorrent.download_manager.download import Download
Expand All @@ -39,17 +39,6 @@ class GlobalTestSettings(CommunitySettings):
node_id: int = 0


class MockTriblerConfigManager(TriblerConfigManager):
"""
A memory-based TriblerConfigManager.
"""

def write(self) -> None:
"""
Don't actually write to any file.
"""


class MockDownloadManager(DownloadManager):
"""
Mocked manager that always allows shutdown (regardless of the libtorrent state).
Expand Down
13 changes: 1 addition & 12 deletions src/tribler/test_integration/test_hidden_services.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
from tribler.core.notifier import Notifier
from tribler.core.socks5.server import Socks5Server
from tribler.core.tunnel.community import TriblerTunnelCommunity, TriblerTunnelSettings
from tribler.tribler_config import TriblerConfigManager
from tribler.test_unit.mocks import MockTriblerConfigManager

if TYPE_CHECKING:
from tribler.core.libtorrent.download_manager.download import Download
Expand All @@ -41,17 +41,6 @@ class GlobalTestSettings(CommunitySettings):
node_id: int = 0


class MockTriblerConfigManager(TriblerConfigManager):
"""
A memory-based TriblerConfigManager.
"""

def write(self) -> None:
"""
Don't actually write to any file.
"""


class MockDownloadManager(DownloadManager):
"""
Mocked manager that always allows shutdown (regardless of the libtorrent state).
Expand Down
103 changes: 0 additions & 103 deletions src/tribler/test_unit/base_restapi.py

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
from ipv8.peerdiscovery.network import Network
from ipv8.test.base import TestBase
from ipv8.test.mocking.endpoint import AutoMockEndpoint
from ipv8.test.REST.rest_base import MockRequest, response_to_json

from tribler.core.content_discovery.community import ContentDiscoveryCommunity
from tribler.core.content_discovery.restapi.search_endpoint import SearchEndpoint
from tribler.core.restapi.rest_endpoint import HTTP_BAD_REQUEST
from tribler.test_unit.base_restapi import MockRequest, response_to_json


class MockContentDiscoveryCommunity(ContentDiscoveryCommunity):
Expand All @@ -33,19 +33,6 @@ def send_search_request(self, **kwargs) -> tuple[UUID, list[Peer]]:
return UUID(int=1), [self.my_peer]


class SearchRequest(MockRequest):
"""
A MockRequest that mimics SearchRequests.
"""

def __init__(self, query: dict) -> None:
"""
Create a new SearchRequest.
"""
super().__init__(query, "PUT", "/search/remote")
self.context = [MockContentDiscoveryCommunity()]


class TestSearchEndpoint(TestBase):
"""
Tests for the SearchEndpoint REST endpoint.
Expand All @@ -56,8 +43,10 @@ async def test_remote_search_bad_request(self) -> None:
Test if a bad request returns the bad request status.
"""
endpoint = SearchEndpoint()
request = MockRequest("/api/search/remote", "PUT", {"channel_pk": "GG"})
request.context = [MockContentDiscoveryCommunity()]

response = await endpoint.remote_search(SearchRequest({"channel_pk": "GG"}))
response = await endpoint.remote_search(request)

self.assertEqual(HTTP_BAD_REQUEST, response.status)

Expand All @@ -66,8 +55,10 @@ async def test_remote_search(self) -> None:
Test if a good search request returns a dict with the UUID and serving peers.
"""
endpoint = SearchEndpoint()
request = MockRequest("/api/search/remote", "PUT", {"channel_pk": "AA", "fts_text": ""})
request.context = [MockContentDiscoveryCommunity()]

response = await endpoint.remote_search(SearchRequest({"channel_pk": "AA", "fts_text": ""}))
response = await endpoint.remote_search(request)
response_body_json = await response_to_json(response)

self.assertEqual(200, response.status)
Expand Down
Loading
Loading