def test_l7policymgr_delete(happy_path_driver): mock_driver, mock_ctx = happy_path_driver l7policy_mgr = dv2.L7PolicyManager(mock_driver) fake_l7policy = FakePolicy() l7policy_mgr.delete(mock_ctx, fake_l7policy) assert mock_driver.agent_rpc.delete_l7policy.call_args == \ mock.call(mock_ctx, fake_l7policy.to_dict(), {}, 'test_agent')
def test_mgr__call_rpc_exception(mock_log, happy_path_driver): mock_driver, mock_ctx = happy_path_driver pol_mgr = dv2.L7PolicyManager(mock_driver) pol_mgr._setup_crud = mock.MagicMock(name='mock_setup_crud', side_effect=Exception('test')) fake_pol = FakePolicy(id='test_lb') with pytest.raises(Exception) as ex: pol_mgr.delete(mock_ctx, fake_pol) assert 'test' == ex.value.message assert mock_log.error.call_args == mock.call( 'Exception: delete_l7policy: test')
def test_mgr__call_rpc_no_eligible_agent_exception(mock_log, happy_path_driver): mock_driver, mock_ctx = happy_path_driver pol_mgr = dv2.L7PolicyManager(mock_driver) pol_mgr._setup_crud = mock.MagicMock( name='mock_setup_crud', side_effect=lbaas_agentschedulerv2.NoEligibleLbaasAgent( loadbalancer_id='test_lb')) fake_pol = FakePolicy(id='test_lb') pol_mgr.delete(mock_ctx, fake_pol) assert mock_log.error.call_args == mock.call( 'Exception: delete_l7policy: No eligible agent found for ' 'loadbalancer test_lb.')
def test_l7policymgr_update(happy_path_driver): mock_driver, mock_ctx = happy_path_driver l7policy_mgr = dv2.L7PolicyManager(mock_driver) fake_old_l7policy = FakePolicy(id='old_policy') fake_new_l7policy = FakePolicy(id='new_policy') l7policy_mgr.update(mock_ctx, fake_old_l7policy, fake_new_l7policy) assert mock_driver.agent_rpc.update_l7policy.call_args == \ mock.call( mock_ctx, fake_old_l7policy.to_dict(), fake_new_l7policy.to_dict(), {}, 'test_agent')