Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions tom_fink/fink.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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

Expand Down
36 changes: 34 additions & 2 deletions tom_fink/tests/tests.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,28 @@
from django.test import TestCase

from tom_fink.fink import FinkBroker
# from tom_fink.fink import FinkQueryForm, FinkBroker

test_alert1 = {
"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 = {
"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):
"""
Expand All @@ -15,8 +36,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)