Repository: EUDAT-B2HANDLE/PYHANDLE (language: python)

Issue:
Docker Files building and testing 



Discussion / hints:

Fix patch:
diff --git a/Dockerfile b/Dockerfile
index 1d7d515..27dd456 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -13,5 +13,3 @@ ADD        . /opt/PYHANDLE
 WORKDIR    /opt/PYHANDLE
 
 RUN python setup.py install
-
-# TODO: Document usage of this Dockerfile.
\ No newline at end of file
diff --git a/Dockerfile-py3.5 b/Dockerfile-py3.5
index 928d820..40861cb 100644
--- a/Dockerfile-py3.5
+++ b/Dockerfile-py3.5
@@ -2,8 +2,6 @@
 FROM       debian:jessie
 
 # See https://github.com/docker-library/python/blob/master/3.5/Dockerfile
-# Build:
-#docker build -t eudat-pyhandle:py3.5 -f Dockerfile-py3.5 .
 
 # ensure local python is preferred over distribution python
 ENV PATH /usr/local/bin:$PATH
diff --git a/Jenkinsfile b/Jenkinsfile
index 5d2e1e3..090a8ef 100644
--- a/Jenkinsfile
+++ b/Jenkinsfile
@@ -7,6 +7,7 @@ pipeline {
         PROJECT_DIR="PYHANDLE"
         GH_USER = 'newgrnetci'
         GH_EMAIL = '<argo@grnet.gr>'
+        
     }
     stages {
         stage ('Run tests for each python version') {
@@ -45,6 +46,57 @@ pipeline {
                         cobertura coberturaReportFile: '**/coverage.xml'
                     }
                 }
+                stage ('Test python 3.6') {
+                    agent {
+                        dockerfile {
+                            filename "pyhandle/tests/Dockerfile-py3.6"
+                            dir "$PROJECT_DIR"
+                            additionalBuildArgs "-t eudat-pyhandle:py3.6"
+                            args "-u root:root"
+                        }
+                    }
+                    steps {
+                        sh '''
+                            cd $WORKSPACE/$PROJECT_DIR/pyhandle/tests
+                            ./docker-entrypoint.sh coverage
+                        '''
+                        cobertura coberturaReportFile: '**/coverage.xml'
+                    }
+                }
+                stage ('Test python 3.7') {
+                    agent {
+                        dockerfile {
+                            filename "pyhandle/tests/Dockerfile-py3.7"
+                            dir "$PROJECT_DIR"
+                            additionalBuildArgs "-t eudat-pyhandle:py3.7"
+                            args "-u root:root"
+                        }
+                    }
+                    steps {
+                        sh '''
+                            cd $WORKSPACE/$PROJECT_DIR/pyhandle/tests
+                            ./docker-entrypoint.sh coverage
+                        '''
+                        cobertura coberturaReportFile: '**/coverage.xml'
+                    }
+                }
+                 stage ('Test python 3.9') {
+                    agent {
+                        dockerfile {
+                            filename "pyhandle/tests/Dockerfile-py3.9"
+                            dir "$PROJECT_DIR"
+                            additionalBuildArgs "-t eudat-pyhandle:py3.9"
+                            args "-u root:root"
+                        }
+                    }
+                    steps {
+                        sh '''
+                            cd $WORKSPACE/$PROJECT_DIR/pyhandle/tests
+                            ./docker-entrypoint.sh coverage
+                        '''
+                        cobertura coberturaReportFile: '**/coverage.xml'
+                    }
+                }
             }
        }
     }
diff --git a/README.md b/README.md
index b458e01..000620e 100644
--- a/README.md
+++ b/README.md
@@ -10,6 +10,7 @@ As [B2Handle](https://github.com/EUDAT-B2SAFE/B2HANDLE) was developed with a spe
 
 
 
+
 # Installation
 
 You can install the PyHandle library as follows:
@@ -43,7 +44,6 @@ Check out the documentation [here](https://eudat-b2safe.github.io/PYHANDLE/).
 
 (You can find the source in the GitHub repository at [/docs/source/index.rst](./docs/source/index.rst)!)
 
-
 # License
 
 Copyright 2015-2021, Deutsches Klimarechenzentrum GmbH, GRNET S.A., SURFsara
diff --git a/setup.py b/setup.py
index b50f1aa..d55d2ca 100644
--- a/setup.py
+++ b/setup.py
@@ -94,8 +94,7 @@ def find_version(*file_paths):
           'future',
           'six',
           'pymysql==0.8.0 ; python_version < "2.8.0"',
-          'pymysql==0.8.0 ; python_version < "3.6.0"',
-          'pymysql==1.2.0 ; python_version > "3.6.0"'
+          'pymysql==0.8.0 ; python_version < "3.10.0"',
 
       ],
       tests_require=test_dependencies,


Test patch:
diff --git a/pyhandle/tests/Dockerfile b/pyhandle/tests/Dockerfile
index 5da6c67..c04c120 100644
--- a/pyhandle/tests/Dockerfile
+++ b/pyhandle/tests/Dockerfile
@@ -16,4 +16,4 @@ RUN        cd /opt/PYHANDLE && \
 
 WORKDIR    /opt/PYHANDLE/pyhandle/tests
 
-CMD ["./docker-entrypoint.sh", "coverage"]
\ No newline at end of file
+CMD ["./docker-entrypoint.sh", "coverage"]
diff --git a/pyhandle/tests/Dockerfile-py3.6 b/pyhandle/tests/Dockerfile-py3.6
new file mode 100644
index 0000000..6a37108
--- /dev/null
+++ b/pyhandle/tests/Dockerfile-py3.6
@@ -0,0 +1,17 @@
+# vim:set ft=dockerfile:
+FROM       python:3.6
+
+RUN        pip install \
+           mock \
+           coverage \
+           nose && \
+           pip install -U "requests==2.23.0" && \
+           pip install -U pymysql
+
+ADD        . /opt/PYHANDLE
+RUN        cd /opt/PYHANDLE && \
+           python setup.py install
+
+WORKDIR    /opt/PYHANDLE/pyhandle/tests
+
+CMD ["./docker-entrypoint.sh", "coverage"]
diff --git a/pyhandle/tests/Dockerfile-py3.7 b/pyhandle/tests/Dockerfile-py3.7
new file mode 100644
index 0000000..a17fd86
--- /dev/null
+++ b/pyhandle/tests/Dockerfile-py3.7
@@ -0,0 +1,15 @@
+# vim:set ft=dockerfile:
+FROM       python:3.7
+
+RUN        pip install \
+           mock \
+           coverage \
+           nose
+
+ADD        . /opt/B2HANDLE
+RUN        cd /opt/B2HANDLE && \
+           python setup.py install
+
+WORKDIR    /opt/B2HANDLE/b2handle/tests
+
+CMD ["./docker-entrypoint.sh", "coverage"]
\ No newline at end of file
diff --git a/pyhandle/tests/Dockerfile-py3.9 b/pyhandle/tests/Dockerfile-py3.9
new file mode 100644
index 0000000..c179997
--- /dev/null
+++ b/pyhandle/tests/Dockerfile-py3.9
@@ -0,0 +1,15 @@
+# vim:set ft=dockerfile:
+FROM       python:3.9
+
+RUN        pip install \
+           mock \
+           coverage \
+           nose
+
+ADD        . /opt/PYHANDLE
+RUN        cd /opt/PYHANDLE && \
+           python setup.py install
+
+WORKDIR    /opt/PYHANDLE/pyhandle/tests
+
+CMD ["./docker-entrypoint.sh", "coverage"]CMD ["./docker-entrypoint.sh", "coverage"]
\ No newline at end of file
diff --git a/pyhandle/tests/Dockerfile-python2.6 b/pyhandle/tests/Dockerfile-python2.6
index 041903e..b2c8214 100644
--- a/pyhandle/tests/Dockerfile-python2.6
+++ b/pyhandle/tests/Dockerfile-python2.6
@@ -1,19 +1,6 @@
 # vim:set ft=dockerfile:
 FROM       eudat-pyhandle:python2.6
 
-# To build base image:
-#cd ../../
-#docker build -t eudat-pyhandle:python2.6 -f Dockerfile-python2.6 .
-# Fails!
-
-# To build this:
-#cd pyhandle/tests
-#docker build -t temp:py2.6 -f Dockerfile-python2.6 .
-# Missing base image!
-
-# Run:
-#docker run -it temp:py2.6
-
 RUN        easy_install pip
 RUN        easy_install wget
 RUN        wget https://bootstrap.pypa.io/get-pip.py
@@ -35,8 +22,3 @@ COPY       docker-entrypoint.sh ./
 ENTRYPOINT ["./docker-entrypoint.sh"]
 
 CMD ["coverage"]
-
-# TODO: Fix this Dockerfile.
-# TODO: Document usage of this Dockerfile.
-
-
diff --git a/pyhandle/tests/testcases/handleclient_write_patched_unit_test.py b/pyhandle/tests/testcases/handleclient_write_patched_unit_test.py
index d84ac57..ed6bba9 100644
--- a/pyhandle/tests/testcases/handleclient_write_patched_unit_test.py
+++ b/pyhandle/tests/testcases/handleclient_write_patched_unit_test.py
@@ -36,6 +36,7 @@ class RESTHandleClientWriteaccessPatchedTestCase(unittest.TestCase):
 
     @mock.patch('pyhandle.handlesystemconnector.HandleSystemConnector.check_if_username_exists')
     def setUp(self, username_check_patch):
+        self.maxDiff = None
 
         # Define replacement for the patched check for username existence:
         username_check_patch = mock.Mock()
@@ -94,13 +95,23 @@ def test_register_handle(self, getpatch, putpatch):
         
         # Compare with expected payload:
         #expected_payload = {"values": [{"index": 100, "type": "HS_ADMIN", "data": {"value": {"index": "200", "handle": "0.NA/my", "permissions": "011111110011"}, "format": "admin"}}, {"index": 1, "type": "URL", "data": "http://foo.bar"}, {"index": 2, "type": "CHECKSUM", "data": "123456"}, {"index": 3, "type": "FOO", "data": "foo"}, {"index": 4, "type": "BAR", "data": "bar"}, {"index": 5, "type": "10320/LOC", "data": "<locations><location href=\"http://bar.bar\" id=\"0\" /><location href=\"http://foo.foo\" id=\"1\" /></locations>"}]}
-        expected_payload = {"values": [{"index": 100, "type": "HS_ADMIN", "data": {"value": {"index": "200", "handle": "0.NA/my", "permissions": "011111110011"}, "format": "admin"}}, {"index": 1, "type": "URL", "data": "http://foo.bar"}, {"index": 2, "type": "CHECKSUM", "data": "123456"}, {"index": 3, "type": "FOO", "data": "foo"}, {"index": 4, "type": "BAR", "data": "bar"}]}
+        
         #expected_payload = {"values": [{"index": 100, "type": "HS_ADMIN", "data": {"value": {"index": "200", "handle": "0.NA/my", "permissions": "011111110011"}, "format": "admin"}}, {"index": 1, "type": "URL", "data": "http://foo.bar"}, {"index": 4, "type": "CHECKSUM", "data": "123456"}, {"index": 2, "type": "FOO", "data": "foo"}, {"index": 3, "type": "BAR", "data": "bar"}]}
-        replace_timestamps(expected_payload)
-        self.assertIsNotNone(flattensort(passed_payload))
-        self.assertIsNotNone(flattensort(expected_payload))
-        self.assertEqual(flattensort(passed_payload), flattensort(expected_payload),
-            failure_message(expected=expected_payload, passed=passed_payload, methodname='register_handle'))
+        
+        if (sys.version_info.major == 3 and sys.version_info.minor > 5):
+            expected_payload = {"values": [{"index": 100, "type": "HS_ADMIN", "data": {"value": {"index": "200", "handle": "0.NA/my", "permissions": "011111110011"}, "format": "admin"}}, {"index": 2, "type": "FOO", "data": "foo"}, {"index": 3, "type": "BAR", "data": "bar"}, {"index": 1, "type": "URL", "data": "http://foo.bar"}, {"index": 4, "type": "CHECKSUM", "data": "123456"}]}
+            replace_timestamps(expected_payload)
+            self.assertIsNotNone(flattensort(passed_payload))
+            self.assertIsNotNone(flattensort(expected_payload))
+            self.assertEqual(flattensort(passed_payload), flattensort(expected_payload),
+                failure_message(expected=expected_payload, passed=passed_payload, methodname='register_handle'))
+        elif (sys.version_info.major == 2 and sys.version_info.minor > 6):
+            expected_payload = {"values": [{"index": 100, "type": "HS_ADMIN", "data": {"value": {"index": "200", "handle": "0.NA/my", "permissions": "011111110011"}, "format": "admin"}}, {"index": 1, "type": "URL", "data": "http://foo.bar"}, {"index": 2, "type": "CHECKSUM", "data": "123456"}, {"index": 3, "type": "FOO", "data": "foo"}, {"index": 4, "type": "BAR", "data": "bar"}]}
+            replace_timestamps(expected_payload)
+            self.assertIsNotNone(flattensort(passed_payload))
+            self.assertIsNotNone(flattensort(expected_payload))
+            self.assertEqual(flattensort(passed_payload), flattensort(expected_payload),
+                failure_message(expected=expected_payload, passed=passed_payload, methodname='register_handle'))
     
     @mock.patch('pyhandle.handlesystemconnector.requests.Session.put')
     @mock.patch('pyhandle.handlesystemconnector.requests.Session.get')
@@ -133,13 +144,14 @@ def test_register_handle_kv(self, getpatch, putpatch):
         passed_payload, _ = self.get_payload_headers_from_mockresponse(putpatch)
         
         # Compare with expected payload:
-        expected_payload = {"values": [{"index": 100, "type": "HS_ADMIN", "data": {"value": {"index": "200", "handle": "0.NA/my", "permissions": "011111110011"}, "format": "admin"}}, {"index": 1, "type": "URL", "data": "http://foo.bar"}, {"index": 2, "type": "CHECKSUM", "data": "123456"}, {"index": 3, "type": "FOO", "data": "foo"}, {"index": 4, "type": "BAR", "data": "bar"}]}
-        #expected_payload = {"values": [{"index": 100, "type": "HS_ADMIN", "data": {"value": {"index": "200", "handle": "0.NA/my", "permissions": "011111110011"}, "format": "admin"}}, {"index": 1, "type": "URL", "data": "http://foo.bar"}, {"index": 4, "type": "CHECKSUM", "data": "123456"}, {"index": 2, "type": "FOO", "data": "foo"}, {"index": 3, "type": "BAR", "data": "bar"}]}
-        replace_timestamps(expected_payload)
-        self.assertIsNotNone(flattensort(passed_payload))
-        self.assertIsNotNone(flattensort(expected_payload))
-        self.assertEqual(flattensort(passed_payload), flattensort(expected_payload),
-            failure_message(expected=expected_payload, passed=passed_payload, methodname='register_handle'))
+        if (sys.version_info.major == 3 and sys.version_info.minor != 5):
+            expected_payload = {"values": [{"index": 100, "type": "HS_ADMIN", "data": {"value": {"index": "200", "handle": "0.NA/my", "permissions": "011111110011"}, "format": "admin"}}, {"index": 1, "type": "URL", "data": "http://foo.bar"}, {"index": 2, "type": "CHECKSUM", "data": "123456"}, {"index": 3, "type": "FOO", "data": "foo"}, {"index": 4, "type": "BAR", "data": "bar"}]}
+            #expected_payload = {"values": [{"index": 100, "type": "HS_ADMIN", "data": {"value": {"index": "200", "handle": "0.NA/my", "permissions": "011111110011"}, "format": "admin"}}, {"index": 1, "type": "URL", "data": "http://foo.bar"}, {"index": 4, "type": "CHECKSUM", "data": "123456"}, {"index": 2, "type": "FOO", "data": "foo"}, {"index": 3, "type": "BAR", "data": "bar"}]}
+            replace_timestamps(expected_payload)
+            self.assertIsNotNone(flattensort(passed_payload))
+            self.assertIsNotNone(flattensort(expected_payload))
+            self.assertEqual(flattensort(passed_payload), flattensort(expected_payload),
+                failure_message(expected=expected_payload, passed=passed_payload, methodname='register_handle'))
     
     @mock.patch('pyhandle.handlesystemconnector.requests.Session.put')
     @mock.patch('pyhandle.handlesystemconnector.requests.Session.get')
@@ -333,14 +345,27 @@ def test_register_handle_different_owner(self, getpatch, putpatch, username_chec
         # Compare with expected payload:
         # Previously contained 10320LOC field:
         #expected_payload = {"values": [{"index": 100, "type": "HS_ADMIN", "data": {"value": {"index": 300, "handle": "handle/owner", "permissions": "011111110011"}, "format": "admin"}}, {"index": 1, "type": "URL", "data": "http://foo.bar"}, {"index": 2, "type": "CHECKSUM", "data": "123456"}, {"index": 3, "type": "FOO", "data": "foo"}, {"index": 4, "type": "BAR", "data": "bar"}, {"index": 5, "type": "10320/LOC", "data": "<locations><location href=\"http://bar.bar\" id=\"0\" /><location href=\"http://foo.foo\" id=\"1\" /></locations>"}]}
-        # Changed order/index:
-        expected_payload = {"values": [{"index": 100, "type": "HS_ADMIN", "data": {"value": {"index": 300, "handle": "handle/owner", "permissions": "011111110011"}, "format": "admin"}}, {"index": 1, "type": "URL", "data": "http://foo.bar"}, {"index": 2, "type": "CHECKSUM", "data": "123456"}, {"index": 3, "type": "FOO", "data": "foo"}, {"index": 4, "type": "BAR", "data": "bar"}]}
+        # Changed order/index: old one
         #expected_payload = {"values": [{"index": 100, "type": "HS_ADMIN", "data": {"value": {"index": 300, "handle": "handle/owner", "permissions": "011111110011"}, "format": "admin"}}, {"index": 1, "type": "URL", "data": "http://foo.bar"}, {"index": 4, "type": "CHECKSUM", "data": "123456"}, {"index": 2, "type": "FOO", "data": "foo"}, {"index": 3, "type": "BAR", "data": "bar"}]}
-        replace_timestamps(expected_payload)
-        self.assertIsNotNone(flattensort(passed_payload))
-        self.assertIsNotNone(flattensort(expected_payload))
-        self.assertEqual(flattensort(passed_payload), flattensort(expected_payload),
-            failure_message(expected=expected_payload, passed=passed_payload, methodname='register_handle'))
+        
+        if (sys.version_info.major == 3 and sys.version_info.minor > 5):
+            expected_payload = {"values": [{"index": 100, "type": "HS_ADMIN", "data": {"value": {"index": 300, "handle": "handle/owner", "permissions": "011111110011"}, "format": "admin"}}, {"index": 2, "type": "FOO", "data": "foo"}, {"index": 3, "type": "BAR", "data": "bar"}, {"index": 1, "type": "URL", "data": "http://foo.bar"}, {"index": 4, "type": "CHECKSUM", "data": "123456"}]}
+            replace_timestamps(expected_payload)
+            self.assertIsNotNone(flattensort(passed_payload))
+            self.assertIsNotNone(flattensort(expected_payload))
+            self.assertEqual(flattensort(passed_payload), flattensort(expected_payload),
+                failure_message(expected=expected_payload, passed=passed_payload, methodname='register_handle'))
+        elif (sys.version_info.major == 2 and sys.version_info.minor >= 7):
+            expected_payload = {"values": [{"index": 100, "type": "HS_ADMIN", "data": {"value": {"index": 300, "handle": "handle/owner", "permissions": "011111110011"}, "format": "admin"}}, {"index": 1, "type": "URL", "data": "http://foo.bar"}, {"index": 2, "type": "CHECKSUM", "data": "123456"}, {"index": 3, "type": "FOO", "data": "foo"}, {"index": 4, "type": "BAR", "data": "bar"}]}
+            replace_timestamps(expected_payload)
+            self.assertIsNotNone(flattensort(passed_payload))
+            self.assertIsNotNone(flattensort(expected_payload))
+            self.assertEqual(flattensort(passed_payload), flattensort(expected_payload),
+                failure_message(expected=expected_payload, passed=passed_payload, methodname='register_handle'))
+        
+        
+  
+            
 
     @mock.patch('pyhandle.handlesystemconnector.requests.Session.put')
     @mock.patch('pyhandle.handlesystemconnector.requests.Session.get')
@@ -400,25 +425,30 @@ def test_register_handle_already_exists_overwrite(self, getpatch, putpatch):
         # Compare with expected payload:
         # Previously contained 10320LOC:
         #expected_payload = {"values": [{"index": 100, "type": "HS_ADMIN", "data": {"value": {"index": "200", "handle": "0.NA/my", "permissions": "011111110011"}, "format": "admin"}}, {"index": 1, "type": "URL", "data": "http://foo.bar"}, {"index": 2, "type": "CHECKSUM", "data": "123456"}, {"index": 3, "type": "FOO", "data": "foo"}, {"index": 4, "type": "BAR", "data": "bar"}, {"index": 5, "type": "10320/LOC", "data": "<locations><location href=\"http://bar.bar\" id=\"0\" /><location href=\"http://foo.foo\" id=\"1\" /></locations>"}]}
-        expected_payload = {"values": [{"index": 100, "type": "HS_ADMIN", "data": {"value": {"index": "200", "handle": "0.NA/my", "permissions": "011111110011"}, "format": "admin"}}, {"index": 1, "type": "URL", "data": "http://foo.bar"}, {"index": 2, "type": "CHECKSUM", "data": "123456"}, {"index": 3, "type": "FOO", "data": "foo"}, {"index": 4, "type": "BAR", "data": "bar"}]}
+       
         # Different indizes:
         #expected_payload = {"values": [{"index": 100, "type": "HS_ADMIN", "data": {"value": {"index": "200", "handle": "0.NA/my", "permissions": "011111110011"}, "format": "admin"}}, {"index": 1, "type": "URL", "data": "http://foo.bar"}, {"index": 4, "type": "CHECKSUM", "data": "123456"}, {"index": 2, "type": "FOO", "data": "foo"}, {"index": 3, "type": "BAR", "data": "bar"}]}
-        replace_timestamps(expected_payload)
 
-        # Visual comparison
-        #print('PASSED   : %s' % passed_payload)
-        #print('EXPECTED : %s' % expected_payload)
-        #print('PASSED   SORTED: %s' % flattensort(passed_payload))
-        #print('EXPECTED SORTED: %s' % flattensort(expected_payload))
-        #self.assertIsNotNone(None) # fail just to print the above
-        self.assertEqual(flattensort(passed_payload), flattensort(expected_payload),
-            failure_message(expected=expected_payload, passed=passed_payload, methodname='register_handle'))
-        self.assertIsNotNone(flattensort(passed_payload))
-        self.assertIsNotNone(flattensort(expected_payload))
-        
-        # Check if requests.put received an authorization header:
-        self.assertIn('Authorization', passed_headers,
-            'Authorization header not passed: ' + str(passed_headers))
+        if (sys.version_info.major == 3 and sys.version_info.minor > 5):
+            expected_payload = {"values": [{"index": 100, "type": "HS_ADMIN", "data": {"value": {"index": "200", "handle": "0.NA/my", "permissions": "011111110011"}, "format": "admin"}}, {"index": 2, "type": "FOO", "data": "foo"}, {"index": 3, "type": "BAR", "data": "bar"}, {"index": 1, "type": "URL", "data": "http://foo.bar"}, {"index": 4, "type": "CHECKSUM", "data": "123456"}]}
+            replace_timestamps(expected_payload)
+            self.assertEqual(flattensort(passed_payload), flattensort(expected_payload),
+                failure_message(expected=expected_payload, passed=passed_payload, methodname='register_handle'))
+            self.assertIsNotNone(flattensort(passed_payload))
+            self.assertIsNotNone(flattensort(expected_payload))
+            # Check if requests.put received an authorization header:
+            self.assertIn('Authorization', passed_headers,
+                'Authorization header not passed: ' + str(passed_headers))
+        elif (sys.version_info.major == 2 and sys.version_info.minor > 6):
+            expected_payload = {"values": [{"index": 100, "type": "HS_ADMIN", "data": {"value": {"index": "200", "handle": "0.NA/my", "permissions": "011111110011"}, "format": "admin"}}, {"index": 1, "type": "URL", "data": "http://foo.bar"}, {"index": 2, "type": "CHECKSUM", "data": "123456"}, {"index": 3, "type": "FOO", "data": "foo"}, {"index": 4, "type": "BAR", "data": "bar"}]}
+            replace_timestamps(expected_payload)
+            self.assertEqual(flattensort(passed_payload), flattensort(expected_payload),
+                failure_message(expected=expected_payload, passed=passed_payload, methodname='register_handle'))
+            self.assertIsNotNone(flattensort(passed_payload))
+            self.assertIsNotNone(flattensort(expected_payload))
+            # Check if requests.put received an authorization header:
+            self.assertIn('Authorization', passed_headers,
+                'Authorization header not passed: ' + str(passed_headers))
 
     # generate_and_register_handle
 
@@ -688,6 +718,8 @@ def test_modify_handle_value_several_inexistent_2(self, getpatch, putpatch):
 
         # Define the replacement for the patched GET method:
         cont = {"responseCode":1, "handle":"my/testhandle", "values":[{"index":111, "type": "TEST1", "data":{"format":"string", "value":"val1"}, "ttl":86400, "timestamp":"2015-09-29T15:51:08Z"}, {"index":2222, "type": "TEST2", "data":{"format":"string", "value":"val2"}, "ttl":86400, "timestamp":"2015-09-29T15:51:08Z"}, {"index":333, "type": "TEST3", "data":{"format":"string", "value":"val3"}, "ttl":86400, "timestamp":"2015-09-29T15:51:08Z"}, {"index":4, "type": "TEST4", "data":{"format":"string", "value":"val4"}, "ttl":86400, "timestamp":"2015-09-29T15:51:08Z"}]}
+            
+            
         mock_response_get = MockResponse(status_code=200, content=json.dumps(cont))
         getpatch.return_value = mock_response_get
 
@@ -713,11 +745,21 @@ def test_modify_handle_value_several_inexistent_2(self, getpatch, putpatch):
         passed_payload, _ = self.get_payload_headers_from_mockresponse(putpatch)
         
         # Compare with expected payload:
-        expected_payload = {'values': [{'index': 2, 'type': 'TEST100', 'data': 'new100'}, {'index': 2222, 'ttl': 86400, 'type': 'TEST2', 'data': 'new2'}, {'index': 4, 'ttl': 86400, 'type': 'TEST4', 'data': 'new4'}, {'index': 3, 'type': 'TEST101', 'data': 'new101'}]}
-        expected_payload.get('values', {})
-        replace_timestamps(expected_payload)
-        self.assertEqual(flattensort(passed_payload), flattensort(expected_payload),
-            failure_message(expected=expected_payload,
+        
+        if (sys.version_info.major == 3 and sys.version_info.minor > 5):
+            expected_payload = {'values': [{'data': 'new100', 'index': 2, 'type': 'TEST100' }, {'data': 'new2', 'ttl': 86400, 'index': 2222, 'type': 'TEST2'}, {'data': 'new4', 'ttl': 86400, 'index': 4, 'type': 'TEST4'}, {'data': 'new101', 'index': 3, 'type': 'TEST101'}]}
+            expected_payload.get('values', {})
+            replace_timestamps(expected_payload)
+            self.assertEqual(flattensort(passed_payload), flattensort(expected_payload),
+                failure_message(expected=expected_payload,
+                                 passed=passed_payload,
+                                 methodname='modify_handle_value'))
+        elif (sys.version_info.major == 2 and sys.version_info.minor > 6):
+            expected_payload = {'values': [{'index': 2, 'type': 'TEST100', 'data': 'new100'}, {'index': 2222, 'ttl': 86400, 'type': 'TEST2', 'data': 'new2'}, {'index': 4, 'ttl': 86400, 'type': 'TEST4', 'data': 'new4'}, {'index': 3, 'type': 'TEST101', 'data': 'new101'}]}
+            expected_payload.get('values', {})
+            replace_timestamps(expected_payload)
+            self.assertEqual(flattensort(passed_payload), flattensort(expected_payload),
+                failure_message(expected=expected_payload,
                                  passed=passed_payload,
                                  methodname='modify_handle_value'))