예제 #1
0
 def test_file(self):
     orig = katpoint.Catalogue([_TRG_A, _TRG_B, _TRG_C])
     with tempfile.NamedTemporaryFile('w', suffix='.csv') as f:
         orig.save(f.name)
         test1 = open_sky_model(f.name)
         test2 = open_sky_model('file://' + f.name + '?format=katpoint')
     assert_equal(orig, test1._catalogue)
     assert_equal(orig, test2._catalogue)
예제 #2
0
    def test_telstate(self):
        client = fakeredis.FakeRedis()
        telstate = katsdptelstate.TelescopeState(
            katsdptelstate.redis.RedisBackend(client))
        # Fake just enough of telstate to keep katdal happy. This isn't all in the right
        # namespace, but that doesn't really matter.
        telstate['stream_name'] = 'sdp_l0'
        telstate_l0 = telstate.view('sdp_l0')
        telstate_l0['stream_type'] = 'sdp.vis'
        telstate_l0['chunk_info'] = {
            'correlator_data': {
                'prefix': '1234567890-sdp-l0',
                'dtype': '<c8',
                'shape': (0, 0, 0)
            }
        }
        telstate_l0['sync_time'] = 1234567890.0
        telstate_l0['first_timestamp'] = 0.0
        telstate_l0['int_time'] = 1.0

        _put_models(telstate, '1234567890', 'continuum',
                    [(_TRG_A, [_TRG_A, _TRG_C])])
        expected = katpoint.Catalogue([_TRG_A, _TRG_C])

        with mock.patch('redis.Redis', return_value=client) as mock_redis:
            test = open_sky_model(
                'redis://invalid:6379/?format=katdal&db=1&capture_block_id=1234567890'
                '&continuum=continuum'
                '&target=A,+radec,+20:00:00.00,+-60:00:00.0,+(200.0+12000.0+1.0+0.5+0.0)'
            )
            mock_redis.assert_called_with(host='invalid',
                                          port=6379,
                                          db=1,
                                          socket_timeout=mock.ANY,
                                          health_check_interval=mock.ANY)
            assert_equal(expected, test._catalogue)
예제 #3
0
 def test_bad_scheme(self):
     with assert_raises(ValueError):
         open_sky_model('ftp://invalid/')
예제 #4
0
 def test_missing_params(self):
     with assert_raises(ValueError):
         open_sky_model('redis://invalid/?capture_block_id=1234567890'
                        '&continuum=continuum&format=katdal')
예제 #5
0
 def test_bad_format(self):
     with assert_raises(ValueError):
         open_sky_model(
             'file:///does_not_exist?format=sir_not_appearing_in_this_codebase'
         )