From b3f4b9a93f69c31a291e9cf59f26350e3e093a1c Mon Sep 17 00:00:00 2001
From: jkuensem <jkuensem@physik.uni-bielefeld.de>
Date: Tue, 24 Mar 2020 21:22:07 +0100
Subject: [PATCH] TMSS-162: Fix bug in unittest setup that silently lets broken
 tests pass (error in range definition)

---
 SAS/TMSS/test/t_tmssapp_scheduling_functional.py      | 8 ++++----
 SAS/TMSS/test/tmss_test_environment_unittest_setup.py | 2 +-
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/SAS/TMSS/test/t_tmssapp_scheduling_functional.py b/SAS/TMSS/test/t_tmssapp_scheduling_functional.py
index f7f792449e4..117ddab761d 100755
--- a/SAS/TMSS/test/t_tmssapp_scheduling_functional.py
+++ b/SAS/TMSS/test/t_tmssapp_scheduling_functional.py
@@ -377,22 +377,22 @@ class SubtaskTestCase(unittest.TestCase):
         url = r_dict['url']
         GET_and_assert_expected_response(self, url, 200, st_test_data)
 
-        # Verify state log count is zero
+        # Verify state log count is 1
         segments = url.split('/')
         identifier = ''
         while identifier == '':
             identifier = segments.pop()
-        GET_and_assert_expected_response(self, BASE_URL + '/subtask_state_log/?subtask=' + identifier, 200, {"count":0})
+        GET_and_assert_expected_response(self, BASE_URL + '/subtask_state_log/?subtask=' + identifier, 200, {"count":1})
 
         # PATCH item with something else than state and verify no log record is created
         test_patch = {"specifications_doc": {"somespec": "somevalue"}}
         PATCH_and_assert_expected_response(self, url, test_patch, 200, test_patch)
-        GET_and_assert_expected_response(self, BASE_URL + '/subtask_state_log/?subtask=' + identifier, 200, {"count": 0})
+        GET_and_assert_expected_response(self, BASE_URL + '/subtask_state_log/?subtask=' + identifier, 200, {"count": 1})
 
         # PATCH item with state update and verify log record is created
         test_patch = {"state": BASE_URL + "/subtask_state/finishing/"}
         PATCH_and_assert_expected_response(self, url, test_patch, 200, test_patch)
-        GET_and_assert_expected_response(self, BASE_URL + '/subtask_state_log/?subtask=' + identifier, 200, {"count": 1})
+        GET_and_assert_expected_response(self, BASE_URL + '/subtask_state_log/?subtask=' + identifier, 200, {"count": 2})
 
 
 class DataproductTestCase(unittest.TestCase):
diff --git a/SAS/TMSS/test/tmss_test_environment_unittest_setup.py b/SAS/TMSS/test/tmss_test_environment_unittest_setup.py
index 128cda77d2a..5425b40a9f8 100644
--- a/SAS/TMSS/test/tmss_test_environment_unittest_setup.py
+++ b/SAS/TMSS/test/tmss_test_environment_unittest_setup.py
@@ -68,7 +68,7 @@ def _call_API_and_assert_expected_response(test_instance, url, call, data, expec
 
     content = response.content.decode('utf-8')
 
-    if response.status_code in range(200, 100):
+    if response.status_code in range(200, 300):
         r_dict = json.loads(content)
         for key, value in expected_content.items():
             if key not in r_dict.keys():
-- 
GitLab