Ejemplo n.º 1
0
def test_get_destinations():
    """Check getting destination urls."""
    with patch('trollmoves.dispatcher.DispatchConfig'):
        with NamedTemporaryFile('w') as the_file:
            fname = the_file.name
            dp = Dispatcher(fname)
            dp.config = yaml.safe_load(test_yaml1)
            msg = Mock()
            msg.subject = '/level2/viirs'
            msg.data = {
                'sensor': 'viirs',
                'product': 'green_snow',
                'platform_name': 'NOAA-20',
                'start_time': datetime(2019, 9, 19, 9, 19),
                'format': 'tif'
            }
            expected_url = 'ftp://ftp.target1.com/input_data/viirs/NOAA-20_201909190919.tif'
            expected_attrs = {'connection_uptime': 20}

            res = dp.get_destinations(msg)
            assert len(res) == 1
            url, attrs, client = res[0]
            assert url == expected_url
            assert attrs == expected_attrs
            assert client == "target1"

            dp.config = yaml.safe_load(test_yaml2)
            res = dp.get_destinations(msg)
            assert len(res) == 2
Ejemplo n.º 2
0
def _get_dispatcher(config):
    with patch('trollmoves.dispatcher.DispatchConfig'):
        with NamedTemporaryFile('w') as fid:
            fname = fid.name
            dispatcher = Dispatcher(fname)
            dispatcher.config = yaml.safe_load(config)
    return dispatcher