async def check_tests(self): iserv.login() current_tests = iserv.get_next_tests() last_tests = tests_collection.find() last_tests_formatted = [{ 'date': i['date'], 'time': i['time'], 'class': i['class'], 'subject': i['subject'] } for i in last_tests] for test in current_tests: if test not in last_tests_formatted: print("new!") subject = test["subject"] date = test["date"] time = test["time"] time_emoji = time_to_emoji(time) course = test["class"] localized_announce = _('New test announced!') text = f"> **:pencil: {localized_announce} :pencil:**\n" \ f"> :abc: {subject}\n" \ f"> :calendar: {date}\n" \ f"> {time_emoji} {time}\n" \ f"> :family: {course}\n" await self.bot.get_channel(config["autoTests"]["channel"] ).send(text) tests_collection.insert_one(test) for test in last_tests_formatted: if test not in current_tests: tests_collection.delete_one(test) print("deleted!")
async def plan_function(self, class_="9f", day=1): print(type(day)) print(day) if day == 1: url = config["plan"]["day1URL"] elif day == 2: url = config["plan"]["day2URL"] else: return _("Day must be either 1 or 2") plan, date, week = iserv.get_untis_substitution_plan(url) text = _(":newspaper: **Substitution Plan** | ") text = text + f":family: {class_} | " \ f":calendar: {week} | " \ f":calendar_spiral: {date}\n\n" if class_ in plan.keys(): for item in plan[class_]: time_emoji = time_to_emoji( f"{random.randint(1, 12)}:{random.randint(0, 60)}") text = text + f"> {time_emoji} **{_('Lesson')} {item['time']}**\n" \ f"> :abc: {item['subject']}\n" \ f"> :green_square: {item['room']}\n" \ f"> :{random.choice(['man', 'woman'])}_teacher: {item['teacher']}\n" \ f"> :family: {item['course']}\n\n" else: text = text + "Nothing found." return text
def test_normal_30(self): converted = time_to_emoji("11:30") self.assertEqual(converted, ":clock1130:")
def test_bigger_twelve(self): converted = time_to_emoji("14:30") self.assertEqual(converted, ":clock230:")
def test_12_50(self): converted = time_to_emoji("12:50") self.assertEqual(converted, ":clock1:")
def test_15_50(self): converted = time_to_emoji("15:50") self.assertEqual(converted, ":clock4:")
def test_11_59(self): converted = time_to_emoji("11:59") self.assertEqual(converted, ":clock12:")