Skip to content

Commit

Permalink
Update metax related confs and take them in use
Browse files Browse the repository at this point in the history
  • Loading branch information
genie9 committed Mar 1, 2022
1 parent 002ee9b commit 28b70f0
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
11 changes: 6 additions & 5 deletions metadata_backend/api/metax_api_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import aiohttp
from aiohttp.web import HTTPBadRequest, HTTPError, HTTPForbidden, HTTPNotFound, Request

from ..conf.conf import metax_config
from ..helpers.logger import LOG
from .middlewares import get_session
from .operators import FolderOperator, Operator, UserOperator
Expand All @@ -24,11 +25,11 @@ def __init__(self, req: Request) -> None:
self.req = req
self.db_client = self.req.app["db_client"]

self.username = os.getenv("METAX_USER", "sd")
self.password = os.getenv("METAX_PASS", "test")
self.metax_url = os.getenv("METAX_URL", "http://localhost:8002")
self.rest_route = "/rest/v2/datasets"
self.publish_route = "/rpc/v2/datasets/publish_dataset"
self.username = metax_config["username"]
self.password = metax_config["password"]
self.metax_url = metax_config["url"]
self.rest_route = metax_config["rest_route"]
self.publish_route = metax_config["publish_route"]

catalog_pid = "urn:nbn:fi:att:data-catalog-sd"

Expand Down
2 changes: 2 additions & 0 deletions metadata_backend/conf/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,4 +164,6 @@ def create_db_client() -> AsyncIOMotorClient:
"username": os.getenv("METAX_USER", "sd"),
"password": os.getenv("METAX_PASS", "test"),
"url": os.getenv("METAX_URL", "http://mockmetax:8002"),
"rest_route": "/rest/v2/datasets",
"publish_route": "/rpc/v2/datasets/publish_dataset",
}
3 changes: 1 addition & 2 deletions tests/integration/mock_metax_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ async def get_dataset(req: web.Request) -> web.Response:
:return: HTTP response with mocked Metax dataset data
"""
metax_id = req.match_info["metax_id"]
# await asyncio.sleep(1)
LOG.info(f"Retrieving Metax dataset {metax_id}")
if not metax_id:
LOG.error("Query params missing Metax ID.")
Expand Down Expand Up @@ -191,7 +190,7 @@ async def delete_dataset(req: web.Request) -> web.Response:
else:
del drafts[metax_id]
LOG.info(f"Deleted Metax dataset with identifier {metax_id}")
return web.Response(status=204)
return web.HTTPNoContent()


async def validate_payload(req: web.Request, draft=True) -> dict:
Expand Down

0 comments on commit 28b70f0

Please sign in to comment.