def test_meetings_of_officehour(self, schema, amount):
     meetings = [
         meeting for meeting, _ in zip(fake_meeting(), range(amount))
     ]
     context = MagicMock()
     context.api.meeting_api.get_meetings_of_officehour_for_date.return_value = (
         meetings)
     query = """
     query meetings($officeHourId: UUID!, $startTime: Int!, $endTime: Int!) {
         meetings(officeHourId: $officeHourId, startTime: $startTime, endTime: $endTime) {
             meetingId
         }
     }
     """
     variables = {
         "officeHourId": str(uuid4()),
         "startTime": fake.pyint(),
         "endTime": fake.pyint(),
     }
     result = schema.execute(query, context=context, variables=variables)
     assert not result.errors
     for expected_meeting, actual_meeting in zip(meetings,
                                                 result.data["meetings"]):
         assert str(
             expected_meeting.meeting_id) == actual_meeting["meetingId"]
     context.api.meeting_api.get_meetings_of_officehour_for_date.assert_called_once_with(
         UUID(variables["officeHourId"]),
         variables["startTime"],
         variables["endTime"],
     )
Ejemplo n.º 2
0
def fake_officehour():
    return OfficeHour(
        uuid4(),
        fake_section(),
        fake.pyint(),
        choice(list(Weekday)),
        [meeting for meeting, _ in zip(fake_meeting(), range(6))],
    )
Ejemplo n.º 3
0
def fake_section(course=None, year=None, semester=None) -> Section:
    course = course or fake_course()
    year = year or int(fake.year())
    semester = semester or choice(list(Semester))
    section_code = fake.pystr()
    instructor = fake_instructor()
    num_students = fake.pyint()
    return Section(course, year, semester, section_code, instructor, num_students)
Ejemplo n.º 4
0
def fake_meeting() -> Iterator[Meeting]:
    while True:
        start_time = fake.date_time()
        yield Meeting(
            meeting_id=uuid4(),
            office_hour_id=uuid4(),
            index=abs(fake.pyint()),
            instructor=fake_instructor(),
            student=fake_student(),
            notes=[],
            comments=[],
            start_time=int(start_time.timestamp()),
        )