Пример #1
0
def test_membermgr_delete_no_lb_attached(happy_path_driver):
    mock_driver, mock_ctx = happy_path_driver
    member_mgr = dv2.MemberManager(mock_driver)
    fake_member = FakeMember(attached_to_lb=False)
    with pytest.raises(dv2.F5NoAttachedLoadbalancerException) as ex:
        member_mgr.delete(mock_ctx, fake_member)
    assert 'Entity has no associated loadbalancer' == ex.value.message
Пример #2
0
def test_membermgr_delete(happy_path_driver):
    mock_driver, mock_ctx = happy_path_driver
    member_mgr = dv2.MemberManager(mock_driver)
    fake_member = FakeMember()
    member_mgr.delete(mock_ctx, fake_member)
    assert mock_driver.agent_rpc.delete_member.call_args == \
        mock.call(mock_ctx, fake_member.to_dict(), {}, 'test_agent')
Пример #3
0
def test_member_update_exception(mock_log, happy_path_driver):
    mock_driver, mock_ctx = happy_path_driver
    mock_driver.agent_rpc.update_member.side_effect = Exception('test')
    member_mgr = dv2.MemberManager(mock_driver)
    fake_old_member = FakeMember(id='old_member')
    fake_new_member = FakeMember(id='new_member')
    with pytest.raises(Exception) as ex:
        member_mgr.update(mock_ctx, fake_old_member, fake_new_member)
    assert 'test' == ex.value.message
    assert mock_log.error.call_args == mock.call(
        'Exception: member update: test')
Пример #4
0
def test_member_update(happy_path_driver):
    mock_driver, mock_ctx = happy_path_driver
    member_mgr = dv2.MemberManager(mock_driver)
    fake_old_member = FakeMember(id='old_member')
    fake_new_member = FakeMember(id='new_member')
    member_mgr.update(mock_ctx, fake_old_member, fake_new_member)
    assert mock_driver.agent_rpc.update_member.call_args == \
        mock.call(
            mock_ctx,
            fake_old_member.to_dict(),
            fake_new_member.to_dict(),
            {},
            'test_agent')