예제 #1
0
 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))
예제 #2
0
 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))
예제 #3
0
 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)
예제 #4
0
 def test_file_loading(self):
     """Test if the load from disk.
     """
     try:
         cal = Ical(TEST_FILE)
     except:
         self.assertTrue(False)
예제 #5
0
 def test_url_loading(self):
     """Test the load from url.
     """
     try:
         cal = Ical(TEST_URL)
     except:
         self.assertTrue(False)
예제 #6
0
 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)
예제 #7
0
파일: main.py 프로젝트: AlEmerich/ical
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)