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

make client testable + first sync test #82

Merged
merged 2 commits into from
Oct 10, 2024

Conversation

eelcovdw
Copy link
Contributor

@eelcovdw eelcovdw commented Oct 10, 2024

Description

includes changes from #79

  • make all calls to server with httpx.Client instead of requests so we can mock with TestClient
  • fix model_dump mode
  • add settings + client_config as optional lifespan argument for test mocking
  • remove global state in client

Affected Dependencies

List any dependencies that are required for this change.

How has this been tested?

  • Describe the tests that you ran to verify your changes.
  • Provide instructions so we can reproduce.
  • List any relevant details for your test configuration.

Checklist

@eelcovdw eelcovdw changed the title make client testable make client testable + first sync test Oct 10, 2024
@abyesilyurt abyesilyurt changed the base branch from main to aziz/request_model October 10, 2024 14:38
@@ -9,7 +9,7 @@
class SyftBaseModel(BaseModel):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❤️

@madhavajay madhavajay self-requested a review October 10, 2024 23:19
@@ -40,6 +40,7 @@ build-backend = "setuptools.build_meta"
# this will be completely ignored in the built wheel
dev-dependencies = [
"bump2version>=1.0.1",
"faker>=30.3.0",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added this coz it was missing

stop_event = Event()


def register(client_config):
response = requests.post(
f"{client_config.server_url}/register",
response = client_config.server_client.post(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

love it

@@ -244,7 +243,7 @@ def push_changes(client_config: ClientConfig, changes: list[FileChange]):
try:
data = {
"email": client_config.email,
"change": change.model_dump(),
"change": change.model_dump(mode="json"),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

id like to move to yaml when we can its much easier to edit in text editors and already enforces line spacing so its much easier to read

@@ -336,15 +335,15 @@ def list_datasites(client_config):
return datasites


def get_remote_state(client_config, sub_path: str):
def get_remote_state(client_config: ClientConfig, sub_path: str):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can rename ClientConfig to just Client

Copy link
Collaborator

@madhavajay madhavajay left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excellent work! 🙌
I think you made all the right decisions to get something in as a first step. ❤️

@madhavajay madhavajay merged commit 423933a into aziz/request_model Oct 10, 2024
1 check passed
@yashgorana yashgorana deleted the eelco/make-client-testable branch October 11, 2024 06:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants