Exemple #1
0
def test_seg_multy_name(conn):
    set_tags(conn, 'song1', 'rating', 'mood')
    set_tags(conn, 'song2', 'rating')
    set_tags(conn, 'song3', 'mood')

    result = find(conn, 'rating and mood')
    assert result == ['song1']

    result = find(conn, 'rating or mood')
    assert result == ['song1', 'song2', 'song3']
Exemple #2
0
def test_seg_anytag(conn):
    set_tags(conn, 'song1', 'mood', rating=5)
    set_tags(conn, 'song2', 'mood', rating=10)
    set_tags(conn, 'song3', rating=10)

    result = find(conn, 'anytag')
    assert result == ['song1', 'song2', 'song3']
Exemple #3
0
def test_seg_complex(conn):
    set_tags(conn, 'song1', 'mood', rating=5)
    set_tags(conn, 'song2', 'mood', rating=10)
    set_tags(conn, 'song3', rating=10)

    result = find(conn, 'rating > 5 and mood')
    assert result == ['song2']
Exemple #4
0
def test_seg_one_name(conn):
    set_tags(conn, 'song1', 'rating')
    set_tags(conn, 'song2', rating=10)
    set_tags(conn, 'song3', rate=1)

    result = find(conn, 'rating')
    assert result == ['song1', 'song2']
Exemple #5
0
def test_seg_compare(conn):
    set_tags(conn, 'song1', rating=3)
    set_tags(conn, 'song2', rating=5)
    set_tags(conn, 'song3', rating=10)
    set_tags(conn, 'song4', rate=9)

    result = find(conn, 'rating > 5')
    assert result == ['song3']

    result = find(conn, 'rating >= 5')
    assert result == ['song2', 'song3']

    result = find(conn, 'rating < 5')
    assert result == ['song1']

    result = find(conn, 'rating <= 5')
    assert result == ['song1', 'song2']

    result = find(conn, 'rating == 5')
    assert result == ['song2']

    result = find(conn, '3 < rating < 10')
    assert result == ['song2']