From 9a2a8a5c25525fb6786b6aa4d6b18227f8794366 Mon Sep 17 00:00:00 2001
From: Christopher Rhodes <christopher.rhodes@embl.de>
Date: Tue, 31 Oct 2023 14:17:22 +0100
Subject: [PATCH] Merge in path-changing API

---
 model_server/api.py |  2 ++
 tests/test_api.py   | 18 +++++++++++++++++-
 2 files changed, 19 insertions(+), 1 deletion(-)

diff --git a/model_server/api.py b/model_server/api.py
index 6e7fb5c3..5752fa4b 100644
--- a/model_server/api.py
+++ b/model_server/api.py
@@ -30,6 +30,8 @@ def list_session_paths():
 
 def change_path(key, path):
     try:
+        if session.get_paths()[key] == path:
+            return session.get_paths()
         session.set_data_directory(key, path)
     except InvalidPathError as e:
         raise HTTPException(
diff --git a/tests/test_api.py b/tests/test_api.py
index f1431ab5..5a307376 100644
--- a/tests/test_api.py
+++ b/tests/test_api.py
@@ -155,4 +155,20 @@ class TestApiFromAutomatedClient(TestServerBaseClass):
         resp_check = requests.get(
             self.uri + 'paths'
         )
-        self.assertEqual(resp_inpath.json()['inbound_images'], resp_check.json()['inbound_images'])
\ No newline at end of file
+        self.assertEqual(resp_inpath.json()['outbound_images'], resp_check.json()['outbound_images'])
+
+    def test_no_change_inbound_path(self):
+        resp_inpath = requests.get(
+            self.uri + 'paths'
+        )
+        resp_change = requests.put(
+            self.uri + f'paths/watch_output',
+            params={
+                'path': resp_inpath.json()['outbound_images']
+            }
+        )
+        self.assertEqual(resp_change.status_code, 200)
+        resp_check = requests.get(
+            self.uri + 'paths'
+        )
+        self.assertEqual(resp_inpath.json()['outbound_images'], resp_check.json()['outbound_images'])
\ No newline at end of file
-- 
GitLab