示例#1
0
def test_group_add_member_no_evt(group, endpoint):
    listener = mock.MagicMock()
    group.add_listener(listener)

    assert endpoint.unique_id not in group
    group.add_member(endpoint, suppress_event=True)
    assert endpoint.unique_id in group
    assert FIXTURE_GRP_ID in endpoint.member_of
    assert listener.member_added.call_count == 0
    assert listener.member_removed.call_count == 0
示例#2
0
def test_group_add_member(group, endpoint):
    listener = mock.MagicMock()
    group.add_listener(listener)

    assert endpoint.unique_id not in group.members
    assert FIXTURE_GRP_ID not in endpoint.member_of
    group.add_member(endpoint)
    assert endpoint.unique_id in group.members
    assert FIXTURE_GRP_ID in endpoint.member_of
    assert listener.member_added.call_count == 1
    assert listener.member_removed.call_count == 0

    listener.reset_mock()
    group.add_member(endpoint)
    assert listener.member_added.call_count == 0
    assert listener.member_removed.call_count == 0

    group.__repr__()
    assert group.name == FIXTURE_GRP_NAME

    with pytest.raises(ValueError):
        group.add_member(endpoint.endpoint_id)