def multi_proxy_creation_test():
    """
    2 bad and one good proxy, the good one should be created
    """
    config = [
        {
            'id': 'proxy_id',
            'class': 'jormungandr.realtime_schedule.timeo.Timeo',
            'args': {
                'service_url': 'http://custom_url.com',
                'timezone': 'Europe/Paris',
                'service_args': {
                    'serviceID': 'custom_id',
                    'EntityID': 'custom_entity',
                    'Media': 'custom_media'
                }
            }
        },
        {
            'id': 'wrong',
            'class': 'wrong_class',
            'args': {}
        },
        {
            # one with no id, shouldn't be created
            'class': 'wrong_class',
            'args': {}
        }
    ]
    manager = RealtimeProxyManager(config)
    assert manager.get('proxy_id') is not None
    assert manager.get('wrong') is None
def realtime_proxy_creation_test():
    """
    simple timeo proxy creation
    """
    config = [{
        'id': 'proxy_id',
        'class': 'jormungandr.realtime_schedule.timeo.Timeo',
        'args': {
            'timezone': 'Europe/Paris',
            'service_url': 'http://custom_url.com',
            'service_args': {
                'serviceID': 'custom_id',
                'EntityID': 'custom_entity',
                'Media': 'custom_media'
            }
        }
    }]

    manager = RealtimeProxyManager(config)

    timeo = manager.get('proxy_id')

    assert timeo
    timeo.service_url = 'http://custom_url.com'
    timeo.service_args = {
        'serviceID': 'custom_id',
        'EntityID': 'custom_entity',
        'Media': 'custom_media'
    }
def wrong_argument_test():
    """
    test with a timeo proxy, but without the mandatory param 'service_url'
    No error is returned, but the proxy is not created
    """
    config = [
        {
            'id': 'proxy_id',
            'class': 'jormungandr.realtime_schedule.timeo.Timeo',
            'args': {
                'timezone': 'Europe/Paris',
                'service_args': {'serviceID': 'custom_id', 'EntityID': 'custom_entity', 'Media': 'custom_media'},
            },
        }
    ]

    manager = RealtimeProxyManager(config)
    assert manager.get('proxy_id') is None
def wrong_realtime_proxy_class_test():
    """
    test with a unknown class
    No error is returned, but the proxy is not created
    """
    config = [
        {
            'id': 'proxy_id',
            'class': 'wrong_class.bob',
            'args': {
                'service_url': 'http://custom_url.com',
                'service_args': {'serviceID': 'custom_id', 'EntityID': 'custom_entity', 'Media': 'custom_media'},
            },
        }
    ]

    manager = RealtimeProxyManager(config)
    assert manager.get('proxy_id') is None