Exemple #1
0
def test_update_cached():
    mock_service = mock.MagicMock(**{'update.return_value': None})

    result = update_service('foo', {'foo': mock_service})

    assert result == {'foo': 'bar', 'last_updated': '2011-12-13'}
    mock_service.update.assert_called_once_with()
Exemple #2
0
def test_update_cached():
    mock_service = mock.MagicMock(**{'update.return_value': None})

    result = update_service('foo', {'foo': mock_service})

    assert result == {'foo': 'bar', 'last_updated': '2011-12-13'}
    mock_service.update.assert_called_once_with()
Exemple #3
0
def test_update_result(logger):
    mock_result = {'foo': 'bar'}
    mock_service = mock.MagicMock(**{'update.return_value': mock_result})

    result = update_service('foo', {'foo': mock_service})

    assert result == mock_result
    logger.warning.assert_not_called()
    mock_service.update.assert_called_once_with()
Exemple #4
0
def test_update_result(logger):
    mock_result = {'foo': 'bar'}
    mock_service = mock.MagicMock(**{'update.return_value': mock_result})

    result = update_service('foo', {'foo': mock_service})

    assert result == mock_result
    logger.warning.assert_not_called()
    mock_service.update.assert_called_once_with()
Exemple #5
0
def test_update_no_result(logger):
    mock_service = mock.MagicMock(**{'update.return_value': None})

    result = update_service('foo', {'foo': mock_service})

    assert result == {}
    logger.warning.assert_called_once_with(
        'no data received for service: %s',
        'foo',
    )
    mock_service.update.assert_called_once_with()
Exemple #6
0
def test_update_no_result(logger):
    mock_service = mock.MagicMock(**{'update.return_value': None})

    result = update_service('foo', {'foo': mock_service})

    assert result == {}
    logger.warning.assert_called_once_with(
        'no data received for service: %s',
        'foo',
    )
    mock_service.update.assert_called_once_with()
Exemple #7
0
def test_update_service_not_found(logger):
    result = update_service('foo', {})

    assert result == {}
    logger.warning.assert_called_once_with('service not found: %s', 'foo')
Exemple #8
0
def test_update_service_not_found(logger):
    result = update_service('foo', {})

    assert result == {}
    logger.warning.assert_called_once_with('service not found: %s', 'foo')