def test_move_weeks(self, mocker): self.mock_pickle(mocker) compo.current_week = "Gandalf the Gray" compo.next_week = "Gandalf the White" compo.move_to_next_week() assert compo.current_week == "Gandalf the White" assert compo.next_week == compo.blank_week()
async def admin_archive_handler(request: web_request.Request) -> web.Response: """Archive current week, move next week to current, and create a new week""" auth_key = request.match_info["authKey"] if not keys.key_valid(auth_key, keys.admin_keys): return web.Response(status=401, text="Invalid or expired admin link") compo.move_to_next_week() return web.Response(status=204, text="Nice")
async def admin_control_handler(request: web_request.Request) -> CoroutineType: auth_key = request.match_info["authKey"] if key_valid(auth_key, admin_keys): this_week = compo.get_week(False) next_week = compo.get_week(True) data = await request.post() def data_param(week, param, field): nonlocal data if field in data: week[param] = data[field] data_param(this_week, "theme", "currentWeekTheme") data_param(this_week, "date", "currentWeekDate") data_param(next_week, "theme", "nextWeekTheme") data_param(next_week, "date", "nextWeekDate") if "submissionsOpen" in data: if data["submissionsOpen"] == "Yes": compo.get_week(True)["submissionsOpen"] = True if data["submissionsOpen"] == "No": compo.get_week(True)["submissionsOpen"] = False if "rolloutWeek" in data: if data["rolloutWeek"] == "on": compo.move_to_next_week() if "newEntryEntrant" in data: new_entry_week = True if "newEntryWeek" in data: new_entry_week = False new_entry_discord_id = None if "newEntryDiscordID" in data: if data["newEntryDiscordID"] != "": try: new_entry_discord_id = int(data["newEntryDiscordID"]) except ValueError: new_entry_discord_id = None compo.create_blank_entry(data["newEntryEntrant"], new_entry_discord_id, new_entry_week) compo.save_weeks() return web.Response(status=204, text="Nice") else: return web.Response(status=404, text="File not found")
def test_move_weeks_dumps(self, mocker): self.mock_pickle(mocker) compo.move_to_next_week() compo.pickle.dump.assert_called()