Exemple #1
0
 def test_serialize(self):
     c = Calendar(target_hours_per_day=timedelta(hours=8.00))
     c = c.add(Day("came 9 left 18", today))
     data = c.dump()
     c2 = Calendar.load(data)
     s = ConsoleDayShower(c2).show_days(today, 1)
     assert re.search("Flex *01:00", s)
Exemple #2
0
 def test_time(self):
     c = Calendar()
     c = c.add(Day("came 9 left 15", today))
     data = c.dump()
     c2 = Calendar.load(data)
     assert c2.days[today].came == time(9)
     assert c2.days[today].left == time(15)
Exemple #3
0
 def test_project(self):
     c = Calendar()
     c = c.add(
         Day(date_=today, project_name="EPG Support", project_time="08:00"))
     c = c.add_project("EPG Support")
     data = c.dump()
     c2 = Calendar.load(data)
     s = ConsoleDayShower(c2).show_days(today, 1)
     assert "EPG Support" in s
     assert "08:00" in s
Exemple #4
0
def get_calendar(path):
    try:
        with open(path, "r") as f:
            data = f.read()
            calendar = Calendar.load(data)
            if not isinstance(calendar, Calendar):
                raise UnreadableCamelFileError(
                    f"File found at {path} not readable. Remove it to "
                    f"create a new one."
                )
    except FileNotFoundError:
        if _can_file_be_created_at(path):
            calendar = Calendar()
        else:
            raise DirectoryDoesNotExistError(
                f"The directory for the specified path {path} does not exist. "
                f"Specify a custom path by setting the %TIMEREPORTER_FILE% "
                f"environment variable."
            )
    return calendar
Exemple #5
0
 def test_serialize(self):
     c = Calendar(default_project_name="Hello world")
     data = c.dump()
     c2 = Calendar.load(data)
     s = ConsoleDayShower(c2).show_days(today, 1)
     assert "Hello world" in s