def test_fail_axis():
    with pytest.raises(ValueError) as ex:
        m = Movie()
        m.add_annotation(axis='1', xy=(0, 1), xy_text=(2, 3), text='')
    assert 'Axis must be an integer got' in str(ex.value)

    with pytest.raises(ValueError) as ex:
        m = Movie()
        m.add_annotation(axis=-1, xy=(0, 1), xy_text=(2, 3), text='')
    assert 'Axis must be positive got' in str(ex.value)
def test_defaults():
    m = Movie()
    m.add_annotation(axis=0, xy=(0, 1), xy_text=(2, 3), text='4', color='blue')
    a = m.annotations[0]
    assert a['type'] == 'annotation'
    assert a['axis'] == 0
    assert a['text'] == '4'
    assert a['xy'] == (0, 1)
    assert a['xy_text'] == (2, 3)
    assert a['axis_type'] == 'image'
    kwargs = a['kwargs']
    assert kwargs['color'] == 'blue'
def test_fail_positions():
    with pytest.raises(ValueError) as ex:
        m = Movie()
        m.add_annotation(axis=0, xy=(0,), xy_text=(2, 3), text='')
    assert 'xy should be an iterable' in str(ex.value)
    with pytest.raises(ValueError) as ex:
        m = Movie()
        m.add_annotation(axis=0, xy='123', xy_text=(2, 3), text='')
    assert 'xy should be an iterable' in str(ex.value)

    with pytest.raises(ValueError) as ex:
        m = Movie()
        m.add_annotation(axis=0, xy=(0, 1), xy_text=(2,), text='')
    assert 'xy_text should be an iterable' in str(ex.value)
    with pytest.raises(ValueError) as ex:
        m = Movie()
        m.add_annotation(axis=0, xy=(0, 1), xy_text='123', text='')
    assert 'xy_text should be an iterable' in str(ex.value)
def test_fail_axis_type():
    with pytest.raises(ValueError) as ex:
        m = Movie()
        m.add_annotation(axis=0, xy=(0, 1), xy_text=(2, 3), text='', axis_type='fail')
    assert 'axis_type should be image or trace' in str(ex.value)