Пример #1
0
def test_school_classcards_get_json(client, web2py):
    """
        Are the class cards returned correctly?
    """
    populate_api_users(web2py)

    populate_school_classcards(web2py, 2)

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

    classcard = web2py.db.school_classcards(1)
    assert json['data'][0]['Name'] == classcard.Name
Пример #2
0
def test_school_classcards_get_json(client, web2py):
    """
        Are the class cards returned correctly?
    """
    populate_api_users(web2py)

    populate_school_classcards(web2py, 2)

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

    classcard = web2py.db.school_classcards(1)
    assert json['data'][0]['Name'] == classcard.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'
    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_subscriptions_get_json(client, web2py):
    """
        Are the subscriptions returned correctly?
    """
    populate_api_users(web2py)

    populate_school_subscriptions(web2py)

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

    subscription = web2py.db.school_subscriptions(1)
    subscription_price = web2py.db.school_subscriptions_price(1)
    assert json['data'][0]['Name'] == subscription.Name
    assert json['data'][0]['Price'] == subscription_price.Price
Пример #5
0
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
Пример #6
0
def test_school_subscriptions_get_json(client, web2py):
    """
        Are the subscriptions returned correctly?
    """
    populate_api_users(web2py)

    populate_school_subscriptions(web2py)

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

    subscription = web2py.db.school_subscriptions(1)
    subscription_price = web2py.db.school_subscriptions_price(1)
    assert json['data'][0]['Name'] == subscription.Name
    assert json['data'][0]['Price'] == subscription_price.Price
def populate_schedule(web2py):
    """
        Sets up a class and API user to test with
    """
    populate_api_users(web2py)

    web2py.db.auth_user.insert(id=2,
                               first_name='Edwin',
                               last_name='van de Ven',
                               email='*****@*****.**',
                               teacher=True)
    web2py.db.auth_user.insert(first_name='Pietje',
                               last_name='Puk',
                               email='*****@*****.**',
                               teacher=True)
    web2py.db.auth_user.insert(first_name='Aimee',
                               last_name='Garcias',
                               email='*****@*****.**',
                               teacher=True)
    web2py.db.school_classtypes.insert(Name='Mysore',
                                       Link='http://www.openstudioproject.com',
                                       Description='Description here',
                                       AllowAPI=True)
    web2py.db.school_classtypes.insert(Name='Led class',
                                       AllowAPI=True)
    web2py.db.school_classtypes.insert(Name='Private',
                                       AllowAPI=False)
    web2py.db.school_locations.insert(Name="Sittard",
                                      AllowAPI=True)
    web2py.db.school_locations.insert(Name="Maastricht",
                                      AllowAPI=False)
    web2py.db.school_levels.insert(Name='Level 1')
    # Monday class + teachers
    web2py.db.classes.insert(school_locations_id=1,
                             school_classtypes_id=1,
                             school_levels_id=1,
                             Week_day=1,
                             Starttime='06:00:00',
                             Endtime='09:00:00',
                             Startdate='2014-01-01',
                             Enddate='',
                             Maxstudents=20,
                             AllowAPI=True)
    web2py.db.classes_teachers.insert(classes_id=1,
                                      auth_teacher_id=2,
                                      auth_teacher_id2=3,
                                      Startdate='2014-01-01')
    # Tuesday class + teachers
    web2py.db.classes.insert(school_locations_id=2,
                             school_classtypes_id=2,
                             school_levels_id=1,
                             Week_day=2,
                             Starttime='06:00:00',
                             Endtime='09:00:00',
                             Startdate='2014-01-01',
                             Enddate='',
                             Maxstudents=20,
                             AllowAPI=True)
    web2py.db.classes_teachers.insert(classes_id=2,
                                      auth_teacher_id=2,
                                      auth_teacher_id2=3,
                                      Startdate='2014-01-01')
    web2py.db.classes_otc.insert(
        classes_id=1,
        ClassDate='2014-01-13',
        auth_teacher_id=4,
        teacher_role=1,
        auth_teacher_id2=3,
        teacher_role2=1
    )
    # web2py.db.classes_subteachers.insert(classes_id=1,
    #                                      ClassDate='2014-01-13',
    #                                      auth_teacher_id=4,
    #                                      auth_teacher_id2=3)
    web2py.db.classes_otc.insert(
        classes_id=1,
        ClassDate='2014-01-20',
        Status='cancelled'
    )
    # web2py.db.classes_cancelled.insert(classes_id=1,
    #                                    ClassDate='2014-01-20')
    web2py.db.school_holidays.insert(Description='Carnavals vakantie',
                                     Startdate='2014-01-27',
                                     Enddate='2014-01-30',
                                     Classes=True)
    web2py.db.school_holidays_locations.insert(
        school_holidays_id = 1,
        school_locations_id = 1 )
    web2py.db.commit()