def test_two_bin(self): """Test when there are two solutions. """ calendar = Ical(TEST_FILE) events = calendar.get_next_bin(2018, 5, 28) self.assertFalse(not events) self.assertEqual(2, len(events))
def test_one_bin(self): """Test when there is just one solution. """ calendar = Ical(TEST_FILE) events = calendar.get_next_bin(2018, 1, 16) self.assertFalse(not events) self.assertEqual(1, len(events))
def test_regularity(self): uids = ["[email protected]", "[email protected]"] calendar = Ical(TEST_FILE) events = calendar.get_next_bin(2018, 5, 28) for e in events: uid = e.get("UID").to_ical().decode("utf-8") self.assertTrue(uid in uids)
def test_file_loading(self): """Test if the load from disk. """ try: cal = Ical(TEST_FILE) except: self.assertTrue(False)
def test_url_loading(self): """Test the load from url. """ try: cal = Ical(TEST_URL) except: self.assertTrue(False)
def test_no_solution(self): """Test when there is no solutions. """ calendar = Ical(TEST_FILE) events = calendar.get_next_bin(2020, 12, 25) self.assertTrue(not events)
import argparse from ical.utilities import Ical FORMAT_DATE = "%Y-%m-%d" if __name__ == "__main__": parser = argparse.ArgumentParser() parser.add_argument("-path", required=True, type=str) parser.add_argument("-y", required=True, type=int) parser.add_argument("-m", required=True, type=int) parser.add_argument("-d", required=True, type=int) args = parser.parse_args() calendar = Ical(args.path) events = calendar.get_next_bin(args.y, args.m, args.d) for i, e in enumerate(events): print("***************\nEvent " + str(i)) calendar.pretty_print(e)