From 0c2b54c07fb61934bd5a57475631b817fdd8f7b7 Mon Sep 17 00:00:00 2001
From: Christopher Rhodes <christopher.rhodes@embl.de>
Date: Fri, 25 Oct 2024 12:01:09 +0200
Subject: [PATCH] Test covers pipeline with simple binary segmentation

---
 tests/base/test_api.py | 21 ++++++++++++++++-----
 1 file changed, 16 insertions(+), 5 deletions(-)

diff --git a/tests/base/test_api.py b/tests/base/test_api.py
index c2218b78..612660e0 100644
--- a/tests/base/test_api.py
+++ b/tests/base/test_api.py
@@ -174,11 +174,22 @@ class TestApiFromAutomatedClient(TestServerBaseClass):
         acc_out = self.get_accessor(accessor_id=acc_id, filename='test_output.tif')
         self.assertEqual(sd, acc_out.shape_dict)
 
-    def test_load_binary_segmentation_model(self):
+    def test_binary_segmentation_model(self):
         mid = self.assertPutSuccess(
-            '/models/seg/binary_threshold/load/', body={'channel': 0, 'tr': 10}
+            '/models/seg/binary_threshold/load/', body={'tr': 10}
         )['model_id']
-        return mid
 
-    def test_use_binary_segmentation_model(self):
-        self.
\ No newline at end of file
+        fname = self.copy_input_file_to_server()
+        acc_id = self.assertPutSuccess(f'accessors/read_from_file/{fname}')
+        r = self.assertPutSuccess(
+            f'pipelines/segment',
+            body={
+                'accessor_id': acc_id,
+                'model_id': mid,
+                'channel': 0,
+                'keep_interm': True,
+            },
+        )
+        acc = self.get_accessor(r['output_accessor_id'])
+        self.assertTrue(all(acc.unique()[0] == [0, 255]))
+        self.assertTrue(all(acc.unique()[1] > 0))
\ No newline at end of file
-- 
GitLab