Exemple #1
0
def test_update_student_id__no_data(client, student, group):
    assert login_student(client, student)
    add_to_group(student, group)

    resp = client.post(reverse("student-change-id"))
    assert resp.status_code == 400
    assert any(t.name == "400.html" for t in resp.templates)
Exemple #2
0
def test_update_student_id__wrong_data(client, student, group):
    assert login_student(client, student)
    add_to_group(student, group)

    data = {"group_name": group.name}

    resp = client.post(
        reverse("student-change-id"),
        json.dumps(data),
        content_type="application/json",
    )
    assert resp.status_code == 400
    assert any(t.name == "400.html" for t in resp.templates)

    data = {"student_id": "1234567"}

    resp = client.post(
        reverse("student-change-id"),
        json.dumps(data),
        content_type="application/json",
    )
    assert resp.status_code == 400
    assert any(t.name == "400.html" for t in resp.templates)

    data = {}

    resp = client.post(
        reverse("student-change-id"),
        json.dumps(data),
        content_type="application/json",
    )
    assert resp.status_code == 400
    assert any(t.name == "400.html" for t in resp.templates)
Exemple #3
0
def test_update_student_id(client, student, group):
    assert login_student(client, student)
    add_to_group(student, group)

    data = {"student_id": "1234567", "group_name": group.name}

    resp = client.post(
        reverse("student-change-id"),
        json.dumps(data),
        content_type="application/json",
    )
    assert resp.status_code == 200
    assert (StudentGroupMembership.objects.get(
        student=student, group=group).student_school_id == data["student_id"])