def test_get_by_nama_dengan_petik():
    valid_data = {
        "name": "Hasan Al-Asy'Ari",
        "nim_jur": "10215043",
        "nim_tpb": "10215043",
        "prodi": "Fisika"
    }
    response = get_data('Hasan Al-Asy\'Ari', 'nama', 0)
    assert response.get("payload")[0] == valid_data
def test_get_by_nama_tidak_lengkap():
    valid_data = {
        "name": "Dewita Sonya Tarabunga",
        "nim_jur": "13515021",
        "nim_tpb": "13515021",
        "prodi": "Teknik Informatika"
    }
    response = get_data('ewita sonya tarabung', 'nama', 0)
    assert response.get("payload")[0] == valid_data
def test_get_by_nama_uppercase():
    valid_data = {
        "name": "Dewita Sonya Tarabunga",
        "nim_jur": "13515021",
        "nim_tpb": "13515021",
        "prodi": "Teknik Informatika"
    }
    response = get_data('DEWITA SONYA TARABUNGA', 'nama', 0)
    assert response.get("payload")[0] == valid_data
def test_get_by_id():
    valid_data = {
        "name": "Dewita Sonya Tarabunga",
        "nim_jur": "13515021",
        "nim_tpb": "13515021",
        "prodi": "Teknik Informatika"
    }
    response = get_data('13515021', 'nim', 0)
    assert response.get("payload")[0] == valid_data
def test_data_page_1():
    # Data setiap page ada 10
    response = get_data('135', 'nim', 1)
    assert len(response.get("payload")) == 10
Beispiel #6
0
def get_data_by_id():
    if request.method == 'GET':
        name = request.args.get('query', default='*', type=str)
        page = request.args.get('page', default=0, type=int)
        data = get_data(name, 'nim', page)
        return response_api(data)