From 96b94f62743d8c31688f04cd0706645fee7ff83a Mon Sep 17 00:00:00 2001
From: Joao Lopes <joao.pedro.batista.lopes@cern.ch>
Date: Tue, 21 Jun 2022 23:10:42 +0200
Subject: [PATCH] Tape REST API tests: Introduce archive_poll_list(..) helper
 function

---
 tape-rest-api/libs/gfal_helper.py | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/tape-rest-api/libs/gfal_helper.py b/tape-rest-api/libs/gfal_helper.py
index dd643ab..1c96718 100644
--- a/tape-rest-api/libs/gfal_helper.py
+++ b/tape-rest-api/libs/gfal_helper.py
@@ -45,3 +45,22 @@ class GfalWrapper:
         # Request still not finished
         return 0, errors
 
+    def archive_poll_list(self, urls):
+        errors = self.context.archive_poll(urls)
+        error_count = 0
+        ontape_count = 0
+
+        for error in errors:
+            if error is None:
+                ontape_count += 1
+            elif error.code != errno.EAGAIN:
+                error_count += 1
+        if error_count == len(errors):
+            return -1, errors
+        elif ontape_count == len(errors):
+            return 1, errors
+        elif (ontape_count + error_count) == len(errors):
+            return 2, errors
+
+        # Request still not finished
+        return 0, errors
-- 
GitLab