def teachers_df() -> DataFrame: # arrange pook.activate() response_json = f""" {{ "teachers": [ {{ "courseId": "{COURSE_ID}", "userId": "{USER_ID}", "profile": {{ "id": "{PROFILE_ID}", "name": {{ "givenName": "{GIVEN_NAME}", "familyName": "{FAMILY_NAME}", "fullName": "{FULL_NAME}" }}, "emailAddress": "{EMAIL_ADDRESS}" }} }} ] }} """ resource = setup_fake_classroom_api([(f"courses/{COURSE_ID}/teachers", response_json)]) # act return request_latest_teachers_as_df(resource, [COURSE_ID])
def courses_df() -> DataFrame: # arrange pook.activate() response_json = f""" {{ "courses": [ {{ "id": "{COURSE_ID}", "name": "{NAME}", "section": "{SECTION}", "descriptionHeading": "{DESCRIPTION_HEADING}", "room": "{ROOM}", "ownerId": "{OWNER_ID}", "creationTime": "{CREATION_TIME}", "updateTime": "{UPDATE_TIME}", "enrollmentCode": "{ENROLLMENT_CODE}", "courseState": "{COURSE_STATE}", "alternateLink": "{ALTERNATE_LINK}", "teacherGroupEmail": "{TEACHER_GROUP_EMAIL}", "courseGroupEmail": "{COURSE_GROUP_EMAIL}", "teacherFolder": {{ "id": "{TEACHER_FOLDER_ID}", "title": "{TEACHER_FOLDER_TITLE}", "alternateLink": "{TEACHER_FOLDER_ALTERNATE_LINK}" }}, "guardiansEnabled": "{GUARDIANS_ENABLED}", "calendarId": "{CALENDAR_ID}" }} ] }} """ resource = setup_fake_classroom_api("courses", response_json) # act return request_latest_courses_as_df(resource)
def submissions_df() -> DataFrame: # arrange pook.activate() response_json = f""" {{ "studentSubmissions": [ {{ "courseId": "{COURSE_ID}", "courseWorkId": "{COURSEWORK_ID}", "id": "{ID}", "userId": "{USER_ID}", "creationTime": "{CREATION_TIME}", "updateTime": "{UPDATE_TIME}", "state": "{STATE}", "late": "{LATE}", "draftGrade": "{DRAFT_GRADE}", "assignedGrade": "{ASSIGNED_GRADE}", "alternateLink": "{ALTERNATE_LINK}", "courseWorkType": "{COURSEWORK_TYPE}", "associatedWithDeveloper": "{ASSOCIATED_WITH_DEVELOPER}", "assignmentSubmission": {{ "attachments": [ {{ "driveFile": {{ "id": "a", "title": "b", "alternateLink": "c", "thumbnailUrl": "d" }} }} ] }}, "submissionHistory": [ {{ "stateHistory": {{ "state": "e", "stateTimestamp": "f", "actorUserId": "g" }} }} ] }} ] }} """ resource = setup_fake_classroom_api([ (f"courses/{COURSE_ID}/courseWork/-/studentSubmissions", response_json) ]) # act return request_latest_submissions_as_df(resource, [COURSE_ID])
def coursework_df() -> DataFrame: # arrange pook.activate() response_json = f""" {{ "courseWork": [ {{ "courseId": "{COURSE_ID}", "id": "{ID}", "title": "{TITLE}", "description": "{DESCRIPTION}", "materials": [ {{ "link": {{ "url": "{MATERIALS_LINK_URL}", "title": "{MATERIALS_LINK_TITLE}", "thumbnailUrl": "{MATERIALS_LINK_THUMBNAIL_URL}" }} }} ], "state": "{STATE}", "alternateLink": "{ALTERNATE_LINK}", "creationTime": "{CREATION_TIME}", "updateTime": "{UPDATE_TIME}", "dueDate": {{ "year": {DUEDATE_YEAR}, "month": {DUEDATE_MONTH}, "day": {DUEDATE_DAY} }}, "dueTime": {{ "hours": {DUETIME_HOURS}, "minutes": {DUETIME_MINUTES} }}, "maxPoints": {MAX_POINTS}, "workType": "{WORK_TYPE}", "submissionModificationMode": "{SUBMISSION_MODIFICATION_MODE}", "assigneeMode": "{ASSIGNEE_MODE}", "creatorUserId": "{CREATOR_USER_ID}", "scheduledTime": "{SCHEDULED_TIME}", "topicId": "{TOPIC_ID}" }} ] }} """ resource = setup_fake_classroom_api([ (f"courses/{COURSE_ID}/courseWork", response_json) ]) # act return request_latest_coursework_as_df(resource, [COURSE_ID])
def courses_df() -> DataFrame: # arrange pook.activate() aliases_response_json = """ { "aliases": [] } """ resource = setup_fake_classroom_api([ ("courses", COURSES_RESPONSE_JSON), (f"courses/{COURSE_ID}/aliases", aliases_response_json), ]) # act return request_latest_courses_as_df(resource)
def usage_df() -> DataFrame: # arrange pook.activate() response_json = f""" {{ "kind": "admin#reports#usageReports", "etag": "a", "usageReports": [ {{ "kind": "admin#reports#usageReport", "date": "2020-08-17", "etag": "b", "entity": {{ "type": "USER", "customerId": "c", "userEmail": "{EMAIL}", "profileId": "e" }}, "parameters": [ {{ "name": "classroom:num_posts_created", "intValue": "{NUM_POSTS_CREATED}" }}, {{ "name": "classroom:last_interaction_time", "datetimeValue": "{LAST_INTERACTION_TIME}" }}, {{ "name": "accounts:last_login_time", "datetimeValue": "{LAST_LOGIN_TIME}" }} ] }} ] }} """ resource = setup_fake_reports_api("usage/users/all/dates/2020-08-17", response_json) # act return request_latest_usage_as_df(resource, datetime(2020, 8, 17, 0, 0), datetime(2020, 8, 17, 12, 0))
def resource_paths() -> List[str]: # arrange pook.activate() pook.get( MOCK_BASE_URL, response_json=fake_base_api_metadata_json, reply=200, ) pook.get( f"{MOCK_BASE_URL}/metadata/", response_json=fake_openapi_metadata_json, reply=200, ) pook.get( f"{MOCK_BASE_URL}/metadata/data/v3/resources/swagger.json", response_json=fake_resource_metadata_json, reply=200, ) # act return get_resource_paths(MOCK_BASE_URL, True)
def mock(): pook.activate() yield pook pook.disable()