def get_listener(name):
    listener = _get_listener(name)

    if not listener:
        raise exc.NotFoundException("Listener not found [name=%s]" % name)

    return listener
def delete_listener(name, session=None):
    listener = _get_listener(name)

    if not listener:
        raise exc.NotFoundException("Listener not found [name=%s]" % name)

    session.delete(listener)
Example #3
0
def delete_member(name, session=None):
    member = _get_member(name)

    if not member:
        raise exc.NotFoundException("Member not found [member_name=%s]" % name)

    session.delete(member)
Example #4
0
def get_member(name):
    member = _get_member(name)

    if not member:
        raise exc.NotFoundException("Member not found [member_name=%s]" % name)

    return member
def update_listener(name, values, session=None):
    listener = _get_listener(name)

    if not listener:
        raise exc.NotFoundException("Listener not found [name=%s]" % name)

    listener.update(values)

    return listener
Example #6
0
def update_member(name, values, session=None):
    member = _get_member(name)

    if not member:
        raise exc.NotFoundException("Member not found [member_name=%s]" % name)

    member.update(values.copy())

    return member
                          protocol_port=LISTENER['protocol_port'],
                          algorithm=LISTENER['algorithm'],
                          created_at=datetime.datetime(1970, 1, 1),
                          updated_at=datetime.datetime(1970, 1, 1))

LISTENER_DB_DICT = LISTENER_DB.to_dict()

FOR_UPDATED_LISTENER = copy.deepcopy(LISTENER_FOR_UPDATE)
UPDATED_LISTENER = copy.deepcopy(LISTENER)
UPDATED_LISTENER_DB = db.Listener(**LISTENER_DB_DICT)

MOCK_LISTENER = mock.MagicMock(return_value=LISTENER_DB)
MOCK_LISTENERS = mock.MagicMock(return_value=[LISTENER_DB])
MOCK_UPDATED_LISTENER = mock.MagicMock(return_value=UPDATED_LISTENER_DB)
MOCK_EMPTY = mock.MagicMock(return_value=[])
MOCK_NOT_FOUND = mock.MagicMock(side_effect=exc.NotFoundException())
MOCK_DUPLICATE = mock.MagicMock(side_effect=exc.DBDuplicateEntryException())
MOCK_DELETE = mock.MagicMock(return_value=None)


class TestListenerController(base.FunctionalTest):
    def setUp(self):
        super(TestListenerController, self).setUp()

        self.driver_origin = driver.LB_DRIVER
        driver.LB_DRIVER = mock.Mock()

    def tearDown(self):
        driver.LB_DRIVER = self.driver_origin

        super(TestListenerController, self).tearDown()