Beispiel #1
0
def test_get_empty():
    #Create class
    POST('/classes?className=test_class')
    #Create group in this class
    POST('/groups?name=test_group&className=test_class&channel=test_channel')

    response = GET('/slackData/group/test_group')
    assert response.status_code == 200
    assert response.json() is not None and response.json()['result'] == ""
Beispiel #2
0
def test_post_delete():
    #NOTE: the format to make a query and how I call the item test_class. Every test class added and removed should be called that.
    POST('/classes?className=test_class')

    response = GET('/classes')
    assert response.status_code == 200
    classList = response.json()
    assert classList[0]["className"] == "test_class"

    DELETE('/classes?className=test_class')
    response = GET('/classes')
    assert response.json() == []
Beispiel #3
0
def test_get_empty():
    POST('/classes?className=test_class')
    POST(
        '/students?firstName=test_firstName&lastName=test_lastName&directoryId=test_directory_id&uid=0'
    )
    POST('/groups?name=test_group&className=test_class&channel=test_channel')
    POST('/student/uid/0/group/test_group')

    response = GET(
        '/elmsData/student/directoryId/test_directory_id/class/test_class')
    assert response.status_code == 200
    assert response.json() is not None and response.json()['result'] == ""
def test_student_in_one_group():
    POST('/students?firstName=testFirst&lastName=testLast&directoryId=testId&uid=0')
    POST('/classes?className=testClass')
    POST('/groups?name=testGroup&className=testClass&channel=testChannel')

    POST('/student/uid/0/group/testGroup')

    resp = GET('/groups/student/directoryId/testId')
    assert resp.status_code == 200

    assert resp.json()[0]['name'] == 'testGroup'
    assert len(resp.json()) == 1
def test_post_delete_basic():
    POST('/classes?className=test_class')
    POST('/groups?name=test_group&className=test_class&channel=test_channel')

    response = GET('/groups')
    assert response.status_code == 200
    groups = response.json()
    assert groups[0]["name"] == "test_group"
    assert len(groups) == 1

    response = DELETE('/groups?name=test_group')
    assert response.status_code == 204
    
    response = GET('/groups')
    assert len(response.json()) == 0
Beispiel #6
0
def test_no_groups():
    POST('/classes?className=test_class')
    POST('/groups?name=test_group&className=test_class&channel=test_channel')

    response = GET('/groups/red')
    assert response.status_code == 200
    assert response.json() == []
def test_post_missing_args():
    response = POST('/groups')
    assert response.status_code == 400

    res = GET('/groups')
    assert res.status_code == 200
    assert res.json() == []
def test_default_health_is_3():
    POST('/classes?className=testClass')
    POST('/groups?name=testGroup&className=testClass&channel=testChannel')

    resp = GET('/group/health/testGroup')
    assert resp.status_code == 200
    assert resp.json()['result'] == 3
Beispiel #9
0
def test_red_groups():
    POST('/classes?className=test_class')
    POST('/groups?name=test_group&className=test_class&channel=test_channel')

    PUT('/group/health/test_group?groupHealth=1')

    response = GET('/groups/red')
    assert response.status_code == 200
    assert len(response.json()) == 1
Beispiel #10
0
def test_one_group():
    POST('/classes?className=test_class')
    POST('/groups?name=test_group&className=test_class&channel=test_channel')
    POST(
        '/students?firstName=test_firstName&lastName=test_lastName&directoryId=test_directory_id&uid=0'
    )
    POST('/student/uid/0/group/test_group')
    response = GET('/groups/student/uid/0')
    assert response.status_code == 200
    len(response.json()) == 1
def test_update_health_arg():
    POST('/classes?className=testClass')
    POST('/groups?name=testGroup&className=testClass&channel=testChannel')

    resp = PUT('/group/health/testGroup?groupHealth=2')
    assert resp.status_code == 204
    health = GET('/group/health/testGroup')

    assert health.status_code == 200
    assert health.json()['result'] == 2
Beispiel #12
0
def test_SQLinjection():
    #Can we trust the session to check?
    POST('/classes?className=test_class')
    POST('/groups?name=test_group&className=test_class&channel=test_channel')

    maliciousQuery = "test_group; DELETE FROM GROUPS WHERE name=test_group;"

    response = GET('/group/health/' + maliciousQuery)

    response = GET('/groups')
    assert len(response.json()) == 1
def test_single_add():
    POST('/classes?className=testClass')
    POST('/groups?name=testGroup&className=testClass&channel=testChannel')
    POST(
        '/students?firstName=testFirst&lastName=testLast&directoryId=testId&uid=0'
    )
    POST('/student/directoryId/testId/group/testGroup')

    resp = GET('/students/group/testGroup')
    assert resp.status_code == 200
    students = resp.json()

    assert len(students) == 1
    assert students[0]['firstName'] == 'testFirst'
    assert students[0]['lastName'] == 'testLast'
    assert students[0]['directoryId'] == 'testId'
    assert students[0]['uid'] == 0
def test_student_in_many_groups():
    POST('/students?firstName=testFirst&lastName=testLast&directoryId=testId&uid=0')
    POST('/classes?className=testClass')
    POST('/groups?name=testGroup&className=testClass&channel=testChannel')
    POST('/groups?name=testGroup2&className=testClass&channel=testChannel2')
    POST('/groups?name=testGroup3&className=testClass&channel=testChannel3')


    POST('/student/uid/0/group/testGroup')
    POST('/student/uid/0/group/testGroup2')
    POST('/student/uid/0/group/testGroup3')


    resp = GET('/groups/student/directoryId/testId')

    assert resp.status_code == 200
    groups = resp.json()

    assert len(groups) == 3
    assert groups[0]['name'] == 'testGroup'
    assert groups[1]['name'] == 'testGroup2'
    assert groups[2]['name'] == 'testGroup3'
def test_get_empty_group():
    POST('/classes?className=testClass')
    POST('/groups?name=testGroup&className=testClass&channel=testChannel')
    resp = GET('/students/group/testGroup')
    assert resp.status_code == 200
    assert resp.json() == []
def test_belongs_to_no_groups():
    POST('/students?firstName=testFirst&lastName=testLast&directoryId=testId&uid=0')

    resp = GET('/groups/student/directoryId/testId')
    assert resp.status_code == 200
    assert resp.json() == []
def test_get_empty():
    response = GET('/groups')
    assert response.status_code == 200
    assert response.json() == []
Beispiel #18
0
def test_get_empty():
    #Just call this with whatever request you need
    response = GET('/classes')
    assert response.status_code == 200
    #NOTE: This JSON isn't in quotes. We can do comparisons with objects.
    assert response.json() == []
Beispiel #19
0
def test_delete_bad_class():
    response = GET('/classes')
    pre = len(response.json())

    response = DELETE('/classes?className=not_a_class')
    assert response.status_code == 404