From 24fab2836189759323b819555e647c836bf65fd9 Mon Sep 17 00:00:00 2001 From: Reuben Jacobs Date: Fri, 19 Jan 2018 10:56:10 -0500 Subject: [PATCH 1/4] fixing issue for python 2.7 where timezone is - GMT and not + GMT --- pyclarity_lims/descriptors.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pyclarity_lims/descriptors.py b/pyclarity_lims/descriptors.py index a5a4c285..fe19a0a3 100644 --- a/pyclarity_lims/descriptors.py +++ b/pyclarity_lims/descriptors.py @@ -758,7 +758,11 @@ def _parse_element(self, element, lims, **kwargs): except ValueError: # support for python 2.7 ignore time zone # use python 3 for timezone support - qt = qt.split('+')[0] + if '+' in qt: + qt = qt.split('+')[0] + else: + qt_array = qt.split('-') + qt = qt_array[0] + qt_array[1] + qt_array[2] queue_date = datetime.datetime.strptime(qt, date_format) list.append(self, (input_art, queue_date, location)) From 065edcfec6bf854da36d67e2fa37b7073bd3eb12 Mon Sep 17 00:00:00 2001 From: Reuben Jacobs Date: Fri, 19 Jan 2018 14:04:57 -0500 Subject: [PATCH 2/4] Adding test for one case where the timezone is a minus and not a plus --- tests/test_descriptors.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/tests/test_descriptors.py b/tests/test_descriptors.py index be7c7310..eae29433 100644 --- a/tests/test_descriptors.py +++ b/tests/test_descriptors.py @@ -750,6 +750,13 @@ def setUp(self): A:2 + + 2011-12-25T01:10:10.050-00:00 + + + A:3 + + '''.format(url='http://testgenologics.com:4040/api/v2')) @@ -776,10 +783,12 @@ def test_parse(self): assert queued_artifacts[0] == qart qart = self.get_queue_art('a2', 'A:2', 200000, datetime.timedelta(0, 3600)) assert queued_artifacts[1] == qart + qart = self.get_queue_art('a3', 'A:3', 50000, datetime.timedelta(0, 0)) + assert queued_artifacts[1] == qart def test_set(self): queued_artifacts = QueuedArtifactList(self.instance1) - qart = self.get_queue_art('a1', 'A:3', 50000, datetime.timedelta(0, 0)) + qart = self.get_queue_art('a1', 'A:4', 50000, datetime.timedelta(0, 0)) with pytest.raises(NotImplementedError): queued_artifacts.append(qart) From 38669c57f94ae357207c84131f7b2fb7664e2ebd Mon Sep 17 00:00:00 2001 From: Reuben Jacobs Date: Fri, 19 Jan 2018 14:09:10 -0500 Subject: [PATCH 3/4] forgot dashes to connect the parts --- pyclarity_lims/descriptors.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyclarity_lims/descriptors.py b/pyclarity_lims/descriptors.py index fe19a0a3..c2ce1adb 100644 --- a/pyclarity_lims/descriptors.py +++ b/pyclarity_lims/descriptors.py @@ -762,7 +762,7 @@ def _parse_element(self, element, lims, **kwargs): qt = qt.split('+')[0] else: qt_array = qt.split('-') - qt = qt_array[0] + qt_array[1] + qt_array[2] + qt = qt_array[0] + "-" + qt_array[1] + "-" + qt_array[2] queue_date = datetime.datetime.strptime(qt, date_format) list.append(self, (input_art, queue_date, location)) From bd76dccdb1578b60b47533388cafbc48696f3ce2 Mon Sep 17 00:00:00 2001 From: Reuben Jacobs Date: Fri, 19 Jan 2018 14:12:58 -0500 Subject: [PATCH 4/4] fixing typo on queued artifacts test_parse to retrieve the correct index of the artifact --- tests/test_descriptors.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_descriptors.py b/tests/test_descriptors.py index eae29433..e4cee667 100644 --- a/tests/test_descriptors.py +++ b/tests/test_descriptors.py @@ -784,7 +784,7 @@ def test_parse(self): qart = self.get_queue_art('a2', 'A:2', 200000, datetime.timedelta(0, 3600)) assert queued_artifacts[1] == qart qart = self.get_queue_art('a3', 'A:3', 50000, datetime.timedelta(0, 0)) - assert queued_artifacts[1] == qart + assert queued_artifacts[2] == qart def test_set(self): queued_artifacts = QueuedArtifactList(self.instance1)