From f81a7d3b960e1dd5fce401623ab069940c74f72c Mon Sep 17 00:00:00 2001
From: goei <goei@astron.nl>
Date: Wed, 26 Feb 2020 15:39:55 +0100
Subject: [PATCH] TMSS-154: Fix in unitttest, taking 'history' into account and
 determine the total of subtasks objects in stead of hardcoded number

---
 SAS/TMSS/test/t_tmssapp_scheduling_functional.py | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/SAS/TMSS/test/t_tmssapp_scheduling_functional.py b/SAS/TMSS/test/t_tmssapp_scheduling_functional.py
index ebe0f0acacc..925ec5c2455 100755
--- a/SAS/TMSS/test/t_tmssapp_scheduling_functional.py
+++ b/SAS/TMSS/test/t_tmssapp_scheduling_functional.py
@@ -1349,6 +1349,15 @@ class SubtaskQuery(unittest.TestCase):
         json_response = response.json()
         self.assertEqual(expected_count, json_response.get('count'))
 
+    @staticmethod
+    def get_total_number_of_subtasks():
+        """
+        Retrieve the total number of current subtasks objects
+        """
+        response = requests.get(BASE_URL + '/subtask/', auth=AUTH)
+        json_response = response.json()
+        return json_response.get('count')
+
     @staticmethod
     def create_cluster_object(cluster_name):
         cluster_data = Cluster_test_data(name=cluster_name)
@@ -1512,8 +1521,10 @@ class SubtaskQuery(unittest.TestCase):
         response = requests.get(BASE_URL + '/subtask/?cluster__name=clusterNotExist', auth=AUTH)
         self.check_response_OK_and_result_count(response, 0)
 
+        # Check how many is 'ALL'
+        total_subtasks = SubtaskQuery.get_total_number_of_subtasks()
         response = requests.get(BASE_URL + '/subtask/?cluster__error_in_query=clusterA', auth=AUTH)
-        self.check_response_OK_and_result_count(response, 82)
+        self.check_response_OK_and_result_count(response, total_subtasks)
 
         period_length_in_days = 50  # max(B+C)
         stop_time = datetime.now()
-- 
GitLab