Skip to content

Commit

Permalink
trying to solve integration tests
Browse files Browse the repository at this point in the history
  • Loading branch information
niklastheman committed Feb 28, 2024
1 parent 7bdc819 commit 36540e9
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 61 deletions.
71 changes: 11 additions & 60 deletions fedn/fedn/network/api/v1/client_routes.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@

from flask import Blueprint, jsonify, request
from flask import Blueprint, jsonify

from fedn.network.storage.statestore.stores.client_store import ClientStore
from fedn.network.storage.statestore.stores.shared import EntityNotFound
# from fedn.network.storage.statestore.stores.client_store import ClientStore

from .shared import (api_version, get_post_data_to_kwargs,
get_typed_list_headers, mdb)
from .shared import (api_version)

bp = Blueprint("client", __name__, url_prefix=f"/api/{api_version}/clients")

client_store = ClientStore(mdb, "network.clients")
# client_store = ClientStore(mdb, "network.clients")


@bp.route("/", methods=["GET"])
Expand Down Expand Up @@ -111,22 +109,7 @@ def get_clients():
message:
type: string
"""
try:
limit, skip, sort_key, sort_order, _ = get_typed_list_headers(request.headers)
kwargs = request.args.to_dict()

clients = client_store.list(limit, skip, sort_key, sort_order, use_typing=False, **kwargs)

result = clients["result"]

response = {
"count": clients["count"],
"result": result
}

return jsonify(response), 200
except Exception as e:
return jsonify({"message": str(e)}), 500
return jsonify({"msg": "hej"}), 200


@bp.route("/list", methods=["POST"])
Expand Down Expand Up @@ -199,21 +182,8 @@ def list_clients():
message:
type: string
"""
try:
limit, skip, sort_key, sort_order, _ = get_typed_list_headers(request.headers)
kwargs = get_post_data_to_kwargs(request)
clients = client_store.list(limit, skip, sort_key, sort_order, use_typing=False, **kwargs)

result = clients["result"]
return jsonify({"msg": "hej"}), 200

response = {
"count": clients["count"],
"result": result
}

return jsonify(response), 200
except Exception as e:
return jsonify({"message": str(e)}), 500


@bp.route("/count", methods=["GET"])
Expand Down Expand Up @@ -267,13 +237,8 @@ def get_clients_count():
message:
type: string
"""
try:
kwargs = request.args.to_dict()
count = client_store.count(**kwargs)
response = count
return jsonify(response), 200
except Exception as e:
return jsonify({"message": str(e)}), 404
return jsonify({"msg": "hej"}), 200



@bp.route("/count", methods=["POST"])
Expand Down Expand Up @@ -319,13 +284,8 @@ def clients_count():
message:
type: string
"""
try:
kwargs = get_post_data_to_kwargs(request)
count = client_store.count(**kwargs)
response = count
return jsonify(response), 200
except Exception as e:
return jsonify({"message": str(e)}), 404
return jsonify({"msg": "hej"}), 200



@bp.route("/<string:id>", methods=["GET"])
Expand Down Expand Up @@ -361,13 +321,4 @@ def get_client(id: str):
message:
type: string
"""
try:
client = client_store.get(id, use_typing=False)

response = client

return jsonify(response), 200
except EntityNotFound as e:
return jsonify({"message": str(e)}), 404
except Exception as e:
return jsonify({"message": str(e)}), 500
return jsonify({"msg": "hej"}), 200
1 change: 0 additions & 1 deletion fedn/fedn/network/api/v1/model_routes.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

from flask import Blueprint, jsonify, request

from fedn.network.storage.statestore.stores.model_store import ModelStore
Expand Down

0 comments on commit 36540e9

Please sign in to comment.