def test_enqueueing_and_popping(input_):
    q = SimpleLabellingQueue()
    for i in range(10):
        q.enqueue(input_)
        id_, datapoint = q.pop()
        assert id_ == i
        assert datapoint == input_ or (np.isnan(input_)
                                       and np.isnan(datapoint))
def test_submitting_list(label1, label2):
    q = SimpleLabellingQueue()
    q.enqueue(1)
    with pytest.raises(ValueError):
        q.submit(0, label1)
    id_, val = q.pop()
    q.submit(id_, [label1, label2])
    assert q.list_labels() == {label1, label2}
def test_undo():
    inp = "input 1"
    q = SimpleLabellingQueue()
    q.enqueue(inp)
    id_, val = q.pop()
    q.submit(id_, "label 1")
    # ensure the queue is empty now:
    with pytest.raises(IndexError):
        q.pop()
    q.undo()
    # see if it's possible to pop now:
    id_, val = q.pop()
    assert val == "input 1"
def test_submitting_text(label1, label2):
    q = SimpleLabellingQueue()
    q.enqueue(1)
    q.enqueue(2)
    with pytest.raises(ValueError):
        q.submit(0, label1)
    id_, val = q.pop()
    q.submit(id_, label1)
    assert q.progress == 0.5
    id_, val = q.pop()
    q.submit(id_, label2)
    assert q.progress == 1
    assert q.list_labels() == {label1, label2}