Commit 029e63ad authored by Tammo Jan Dijkema's avatar Tammo Jan Dijkema
Browse files

Test output of track_doppler

parent c869c336
import track_doppler
import unittest
from mock import call, patch
from mock import call, patch, PropertyMock
import mock
import mock.mock
from astropy.time import Time
import track_doppler
import threading
import astropy.units as u
from astropy.coordinates import SkyCoord, EarthLocation
import astropy.units as u
......@@ -24,6 +23,9 @@ class DopplerTrackingTest(unittest.TestCase):
self.local_oscillator_mock = local_oscillator_patcher.start()
self.addCleanup(local_oscillator_patcher.stop)
self.frequency_mock = PropertyMock()
type(self.local_oscillator_mock).frequency = self.frequency_mock
self.test_time = Time("2018-06-21T12:00:00", scale="utc", format="isot")
self.test_skycoord = SkyCoord(ra=0. * u.deg, dec=31. * u.deg)
self.test_location = EarthLocation.from_geodetic(lat=52 * u.deg, lon=6 * u.deg, height=0 * u.m)
......@@ -56,18 +58,18 @@ class DopplerTrackingTest(unittest.TestCase):
return self.event_called >= 3
def no_doppler_function(a, b, c, d):
return 42*u.Hz
return 1*u.GHz-42*u.MHz
exit_event.is_set = three_times
track_doppler.track_doppler(self.telescope_mock, self.local_oscillator_mock,
exit_event=exit_event, timeout=0.,
doppler_function=no_doppler_function)
print(self.local_oscillator_mock.mock_calls)
# track_doppler.track_doppler(DummyTelescope(), DummyLocalOscillator())
# track_doppler.track_doppler(DummyTelescope(), DummyLocalOscillator(), doppler_function=doppler_frequency)
self.assertAlmostEqual(self.frequency_mock.mock_calls[0][1][0].value,
(track_doppler.freq_hi + 42 * u.MHz).to(u.GHz).value)
self.assertAlmostEqual(self.frequency_mock.mock_calls[1][1][0].value,
(track_doppler.freq_hi + 42 * u.MHz).to(u.GHz).value)
self.assertAlmostEqual(self.frequency_mock.mock_calls[2][1][0].value, 1.0)
if __name__ == '__main__':
unittest.main()
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment