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

run plugins manually in test #96

Merged
merged 2 commits into from
Oct 11, 2024
Merged
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
15 changes: 11 additions & 4 deletions tests/sync/sync_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@

from syftbox.client.client import app as client_app
from syftbox.client.client import lifespan as client_lifespan
from syftbox.client.plugins.create_datasite import run as run_create_datasite_plugin
from syftbox.client.plugins.init import run as run_init_plugin
from syftbox.client.plugins.sync import do_sync
from syftbox.lib.lib import ClientConfig, perm_file_path
from syftbox.server.server import app as server_app
Expand All @@ -67,7 +69,7 @@ def datasite_1(
sync_folder=str(client_path / "sync"),
email=email,
server_url=str(server_client.base_url),
autorun_plugins=["init", "create_datasite"],
autorun_plugins=[],
)

client_config._server_client = server_client
Expand All @@ -78,6 +80,12 @@ def datasite_1(
yield client


def setup_datasite(datasite: TestClient):
run_init_plugin(datasite.app.shared_state)
run_create_datasite_plugin(datasite.app.shared_state)
wait_for_datasite_setup(datasite)


@pytest.fixture(scope="function")
def server_client(tmp_path: Path) -> Generator[TestClient, None, None]:
path = tmp_path / "server"
Expand All @@ -97,7 +105,7 @@ def http_server_client():
yield client


def wait_for_datasite_setup(datasite: TestClient, timeout=20):
def wait_for_datasite_setup(datasite: TestClient, timeout=5):
print("waiting for datasite setup...")

client_config: ClientConfig = datasite.app.shared_state.client_config
Expand Down Expand Up @@ -127,8 +135,7 @@ def test_sync_file_to_server_snapshot(
tmp_path: Path, server_client: TestClient, datasite_1: TestClient
):
print(datasite_1.app.shared_state.client_config)

wait_for_datasite_setup(datasite_1)
setup_datasite(datasite_1)

do_sync(datasite_1.app.shared_state)

Expand Down