Example #1
0
def test_lazy_load_doesnt_load_data_on_subsequent_calls(mocker):
    load_stations = mocker.patch('herdcats.tube._load_stations')
    load_connections = mocker.patch('herdcats.tube._load_connections')
    mocker.patch('herdcats.tube.STATIONS', {})
    mocker.patch('herdcats.tube.CONNECTIONS', {})
    func = mocker.Mock()
    decorated_func = tube._lazy_load_data(func)

    decorated_func()

    load_stations.assert_not_called()
    load_connections.assert_not_called()
Example #2
0
def test_lazy_load_loads_data_on_first_call(mocker):
    mocker.patch('herdcats.tube.STATIONS', None)
    mocker.patch('herdcats.tube.CONNECTIONS', None)
    load_stations = mocker.patch('herdcats.tube._load_stations')
    load_connections = mocker.patch('herdcats.tube._load_connections')
    func = mocker.Mock()
    decorated_func = tube._lazy_load_data(func)

    decorated_func()

    load_stations.assert_called_once_with()
    load_connections.assert_called_once_with()