From 48d0d45885e87222bd4c6c2c7261a2163e2d711d Mon Sep 17 00:00:00 2001 From: brendanrmills Date: Fri, 24 Jun 2022 11:35:45 -0700 Subject: [PATCH 1/4] added clean date function --- tom_fink/fink.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tom_fink/fink.py b/tom_fink/fink.py index 52484d5..660c2f2 100644 --- a/tom_fink/fink.py +++ b/tom_fink/fink.py @@ -307,6 +307,8 @@ def fetch_alerts(self, parameters: dict) -> iter: r.raise_for_status() data = r.json() + for d in data: + d = self._clean_date(d) return iter(data) @@ -332,8 +334,14 @@ def fetch_alert(self, id: str): ) r.raise_for_status() data = r.json() + data = self._clean_date(data) return data + def _clean_date(self, parameters): + parameters['v:firstdate'] += ' UTC' + parameters['v:lastdate'] += ' UTC' + return parameters + def process_reduced_data(self, target, alert=None): pass From d067dfdf86dafc5134a8c12e6e29407ea2fda66d Mon Sep 17 00:00:00 2001 From: brendanrmills Date: Fri, 1 Jul 2022 11:42:47 -0700 Subject: [PATCH 2/4] targetExtra timezone support --- tom_fink/tests/tests.py | 38 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 36 insertions(+), 2 deletions(-) diff --git a/tom_fink/tests/tests.py b/tom_fink/tests/tests.py index 2d13cdd..fc45a21 100644 --- a/tom_fink/tests/tests.py +++ b/tom_fink/tests/tests.py @@ -1,7 +1,30 @@ from django.test import TestCase - +from tom_fink.fink import FinkBroker # from tom_fink.fink import FinkQueryForm, FinkBroker +test_alert1 = { + "d:cdsxmatch": "RRLyr", + "i:candid": 1333145050315015017, + "i:dec": 36.89327, + "i:objectId": "ZTF18aaavxvj", + "i:publisher": "Fink", + "i:ra": 273.8834457, + "v:classification": "RRLyr", + "v:lastdate": "2020-08-26 03:28:53.003", + "v:firstdate": "2018-02-07 12:46:49.996", + } + +test_alert2 = { + "d:cdsxmatch": "RRLyr", + "i:candid": 1333145050315015017, + "i:dec": 36.89327, + "i:objectId": "ZTF18aaavxvj", + "i:publisher": "Fink", + "i:ra": 273.8834457, + "v:classification": "RRLyr", + "v:lastdate": "2020-08-26 03:28:53.003 UTC", + "v:firstdate": "2018-02-07 12:46:49.996 UTC", + } class TestFinkQueryForm(TestCase): """ @@ -15,8 +38,19 @@ def test_boilerplate(self): self.assertTrue(True) + + class TestFinkBrokerClass(TestCase): """NOTE: To run these tests in your venv: python ./tom_fink/tests/run_tests.py""" def setUp(self): - pass + self.test_data = test_alert1 + self.expected_alert = test_alert2 + + def test_clean_date(self): + test_alert = self.test_data + new_alert = FinkBroker()._clean_date(self, test_alert) + self.assertEqual(test_alert, new_alert) + + + From 2cc4a5223b56117759dc6c3ba05eee75047a3042 Mon Sep 17 00:00:00 2001 From: brendanrmills Date: Fri, 1 Jul 2022 11:44:35 -0700 Subject: [PATCH 3/4] added testing for _clean_date --- tom_fink/tests/tests.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/tom_fink/tests/tests.py b/tom_fink/tests/tests.py index fc45a21..a4a9bb8 100644 --- a/tom_fink/tests/tests.py +++ b/tom_fink/tests/tests.py @@ -2,8 +2,7 @@ from tom_fink.fink import FinkBroker # from tom_fink.fink import FinkQueryForm, FinkBroker -test_alert1 = { - "d:cdsxmatch": "RRLyr", +test_alert1 = {, "i:candid": 1333145050315015017, "i:dec": 36.89327, "i:objectId": "ZTF18aaavxvj", @@ -15,7 +14,6 @@ } test_alert2 = { - "d:cdsxmatch": "RRLyr", "i:candid": 1333145050315015017, "i:dec": 36.89327, "i:objectId": "ZTF18aaavxvj", From 1bb1572acd6c4b127c07140546dc7973db5cf937 Mon Sep 17 00:00:00 2001 From: Joey Chatelain <32683393+jchate6@users.noreply.github.com> Date: Wed, 17 Jan 2024 11:04:30 -0800 Subject: [PATCH 4/4] Update tests.py --- tom_fink/tests/tests.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tom_fink/tests/tests.py b/tom_fink/tests/tests.py index a4a9bb8..b6a5e72 100644 --- a/tom_fink/tests/tests.py +++ b/tom_fink/tests/tests.py @@ -2,7 +2,7 @@ from tom_fink.fink import FinkBroker # from tom_fink.fink import FinkQueryForm, FinkBroker -test_alert1 = {, +test_alert1 = { "i:candid": 1333145050315015017, "i:dec": 36.89327, "i:objectId": "ZTF18aaavxvj",