Beispiel #1
0
def test_delete_preset(client):
    Preset.create(name='p1')

    assert Preset.select().count() == 1

    rv = client.delete('/api/presets/1')

    assert rv.status_code == 204
    assert Preset.select().count() == 0
Beispiel #2
0
def test_delete_reorders_presets(client):
    p1 = Preset.create(name='p1')
    Preset.create(name='p2')
    p3 = Preset.create(name='p3')

    rv = client.delete('/api/presets/2')

    assert rv.status_code == 204
    assert Preset.select().count() == 2
    assert Preset.get(Preset.id == p1.id).number == 1
    assert Preset.get(Preset.id == p3.id).number == 2
Beispiel #3
0
def test_get_preset(client):
    Preset.create(name='p1', data='{}')

    rv = client.get('/api/presets/1')

    expected = {
        'id': 1,
        'name': 'p1',
        'number': 1,
    }

    assert rjson(rv) == expected
    assert rv.status_code == 200
Beispiel #4
0
def test_list_presets(client):
    p1 = Preset(name='p1')
    p1.set_data({
        'voices': {
            'melody': [{
                'soundfont': 'test',
            }],
            'drone': [],
            'trompette': [],
        }
    })
    p1.save()

    Preset.create(name='p2', data='{}')

    rv = client.get('/api/presets')

    assert rjson(rv) == [
        {
            'id': 1,
            'name': 'p1',
            'number': 1,
            'voices': {
                'melody': [{
                    'soundfont': 'test',
                    'bank': 0,
                    'program': 0,
                    'note': 60,
                    'polyphonic': False,
                    'muted': True,
                    'capo': 0,
                    'volume': 127,
                    'panning': 64,
                    'mode': 'midigurdy',
                    'finetune': 0,
                    'chien_threshold': 50,
                }],
                'trompette': [],
                'drone': [],
            }
        },
        {
            'id': 2,
            'name': 'p2',
            'number': 2,
        },
    ]

    assert rv.status_code == 200
Beispiel #5
0
def test_load_preset(db, handler):
    p = Preset.create(name='P1')
    # load preset shows a loading page, so we need a home to return
    # back to...
    handler.menu.register_page('home', Page)

    assert handler.state.last_preset_number == 0

    handler.load_preset(_evt('', '', p.number))

    assert handler.state.last_preset_number == p.number
Beispiel #6
0
def test_load_preset(client):
    Preset.create(name='p1')
    Preset.create(name='p2')
    Preset.create(name='p3')

    rv = client.post('/api/presets/3/load')

    assert rv.status_code == 204
Beispiel #7
0
def test_order_presets(client):
    Preset.create(name='p1')
    Preset.create(name='p2')
    Preset.create(name='p3')

    order = [3, 1, 2]

    rv = client.post('/api/presets/order',
                     data=json.dumps({'order': order}),
                     content_type='application/json')

    assert rv.status_code == 200
    assert rjson(rv) == {'order': order}

    assert Preset.get(Preset.id == 3).number == 1
    assert Preset.get(Preset.id == 1).number == 2
    assert Preset.get(Preset.id == 2).number == 3