Skip to content

Commit

Permalink
feat(watcher): scanning a managed workspace only logs a warning msg
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinBelthle committed Jul 25, 2023
1 parent 787fdc3 commit b6b0367
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 10 deletions.
5 changes: 4 additions & 1 deletion antarest/study/storage/rawstudy/watcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,10 @@ def oneshot_scan(
"""

def scan_task(notifier: TaskUpdateNotifier) -> TaskResult:
self.scan(workspace, path)
try:
self.scan(workspace, path)
except CannotScanInternalWorkspace as e:
logger.warning(e)
return TaskResult(success=True, message="Scan completed")

return self.task_service.add_task(
Expand Down
30 changes: 21 additions & 9 deletions tests/integration/test_integration_watcher.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,32 @@
from fastapi import FastAPI
from starlette.testclient import TestClient

from antarest.core.tasks.model import TaskStatus

def test_integration_xpansion(app: FastAPI, tmp_path: str):
client = TestClient(app, raise_server_exceptions=False)

def test_integration_watcher(app: FastAPI, tmp_path: str):
client = TestClient(app)
res = client.post(
"/v1/login", json={"username": "admin", "password": "admin"}
)
admin_credentials = res.json()
headers = {"Authorization": f'Bearer {admin_credentials["access_token"]}'}

client.post(
f"/v1/watcher/_scan",
headers=headers,
)
client.post(
f"/v1/watcher/_scan?path=/tmp",
res = client.post("/v1/watcher/_scan", headers=headers)
assert res.status_code == 422
assert res.json() == {
"description": "field required",
"exception": "RequestValidationError",
"body": None,
}

task_id = client.post(
"/v1/watcher/_scan?path=/default",
headers=headers,
)
).json()

# asserts that scanning default workspace doesn't fail
res = client.get(
f"v1/tasks/{task_id}?wait_for_completion=true", headers=headers
).json()
assert res["status"] == TaskStatus.COMPLETED.value

0 comments on commit b6b0367

Please sign in to comment.