def test_school_teachers_get_json(client, web2py):
    """
        Are the teachers returned correctly?
    """
    from populate_os_tables import populate_auth_user_teachers

    populate_api_users(web2py)

    populate_auth_user_teachers(web2py)

    url = base_url + '/api/school_teachers_get.json?user=test&key=test'
    page = urllib.urlopen(url).read()
    json = sj.loads(page)

    teacher = web2py.db.auth_user(2)
    assert json['data'][0]['Name'] == teacher.full_name
def test_school_teachers_get_json(client, web2py):
    """
        Are the teachers returned correctly?
    """
    from populate_os_tables import populate_auth_user_teachers

    populate_api_users(web2py)

    populate_auth_user_teachers(web2py)

    url = base_url + '/api/school_teachers_get.json?user=test&key=test'
    with urllib.request.urlopen(url) as page:
        content = page.read().decode('utf-8')
    json = sj.loads(content)

    teacher = web2py.db.auth_user(2)
    assert json['data'][0]['Name'] == teacher.full_name
def test_payment_fixed_rate_default_add(client, web2py):
    """
        Can we add a default rate
    """
    populate_auth_user_teachers(web2py)

    url = '/teachers/payment_fixed_rate_default?teID=2'
    client.get(url)
    assert client.status == 200

    data = {'ClassRate': '30', 'tax_rates_id': 1}

    client.post(url, data=data)
    assert client.status == 200

    row = web2py.db.teachers_payment_fixed_rate_default(1)
    assert row.ClassRate == float(data['ClassRate'])
    assert row.tax_rates_id == data['tax_rates_id']
    assert row.auth_teacher_id == 2