""" Utils for the discussion app. """ def make_minimal_cs_thread(overrides=None): """ Create a dictionary containing all needed thread fields as returned by the comments service with dummy data and optional overrides """ ret = { "type": "thread", "id": "dummy", "course_id": "course-v1:dummy+dummy+dummy", "commentable_id": "dummy", "group_id": None, "user_id": "0", "username": "dummy", "anonymous": False, "anonymous_to_peers": False, "created_at": "1970-01-01T00:00:00Z", "updated_at": "1970-01-01T00:00:00Z", "last_activity_at": "1970-01-01T00:00:00Z", "thread_type": "discussion", "title": "dummy", "body": "dummy", "pinned": False, "closed": False, "abuse_flaggers": [], "abuse_flagged_count": None, "votes": {"up_count": 0}, "comments_count": 0, "unread_comments_count": 0, "children": [], "read": False, "endorsed": False, "resp_total": 0, "closed_by": None, "close_reason_code": None, } ret.update(overrides or {}) return ret def make_minimal_cs_comment(overrides=None): """ Create a dictionary containing all needed comment fields as returned by the comments service with dummy data and optional overrides """ ret = { "type": "comment", "id": "dummy", "commentable_id": "dummy", "thread_id": "dummy", "parent_id": None, "user_id": "0", "username": "dummy", "anonymous": False, "anonymous_to_peers": False, "created_at": "1970-01-01T00:00:00Z", "updated_at": "1970-01-01T00:00:00Z", "body": "dummy", "abuse_flaggers": [], "votes": {"up_count": 0}, "endorsed": False, "child_count": 0, "children": [], } ret.update(overrides or {}) return ret