Ejemplo n.º 1
0
def test_one_host():
    host1 = 'host1'
    slave1 = Slave(host1, 'slave1')
    slave2 = Slave(host1, 'slave2')

    # Create a new slaves list.
    slaves = IdleSlaves()

    # Add some slaves.
    slaves.add(slave1)
    assert slaves._max_count == 1
    slaves.add(slave2)
    assert slaves._max_count == 2

    # Remove some slaves.
    slaves.remove(slave1)
    assert slaves._max_count == 1
    with pytest.raises(KeyError):
        slaves.remove(slave1)
    assert slaves._max_count == 1
    slaves._consistency_check()
    slaves.remove(slave2)
    assert slaves._max_count == 0
    slaves._consistency_check()

    with pytest.raises(KeyError):
        slaves.pop()
def test_one_host():
    host1 = 'host1'
    slave1 = Slave(host1, 'slave1')
    slave2 = Slave(host1, 'slave2')

    # Create a new slaves list.
    slaves = IdleSlaves()

    # Add some slaves.
    slaves.add(slave1)
    assert slaves._max_count == 1
    slaves.add(slave2)
    assert slaves._max_count == 2

    # Remove some slaves.
    slaves.remove(slave1)
    assert slaves._max_count == 1
    with pytest.raises(KeyError):
        slaves.remove(slave1)
    assert slaves._max_count == 1
    slaves._consistency_check()
    slaves.remove(slave2)
    assert slaves._max_count == 0
    slaves._consistency_check()

    with pytest.raises(KeyError):
        slaves.pop()