Esempio n. 1
0
    def test_only_came(self):
        d = Day("came 9")
        assert str(d.came) == "09:00"
        assert d.left is None
        assert d.lunch is None

        d = Day("came 09:00")
        assert str(d.came) == "09:00"

        d = Day("came 9:00")
        assert str(d.came) == "09:00"
Esempio n. 2
0
    def test_different_formatting(self):
        d = Day("came 9:00 left 15:00")
        assert str(d.came) == "09:00"
        assert str(d.left) == "15:00"

        d = Day("came 9 left 15:00")
        assert str(d.came) == "09:00"
        assert str(d.left) == "15:00"

        d = Day("came 9 left 15")
        assert str(d.came) == "09:00"
        assert str(d.left) == "15:00"
Esempio n. 3
0
    def test_only_lunch(self):
        d = Day("lunch 45min")
        assert d.came is None
        assert d.left is None
        assert str(d.lunch) == "00:45"

        d = Day("lunch 45m")
        assert str(d.lunch) == "00:45"

        d = Day("lunch 45 m")
        assert str(d.lunch) == "00:45"

        d = Day("lunch 45min")
        assert str(d.lunch) == "00:45"
Esempio n. 4
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)
Esempio n. 5
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)
Esempio n. 6
0
 def test_only_came(self):
     c = Calendar()
     c = c.add(Day("came 9", today))
     assert "09:00" in ConsoleDayShower(c).show_days(today, 1)
     c, date_ = c.undo()
     assert "09:00" not in ConsoleDayShower(c).show_days(today, 1)
     assert date_ == today
Esempio n. 7
0
 def test_basic(self):
     c = Calendar()
     c = c.add(Day("came 9 left 15 lunch 30m", today))
     c, _ = c.undo()
     c, date_ = c.redo()
     assert "30" in ConsoleDayShower(c).show_days(today, 1)
     assert date_ == today
Esempio n. 8
0
 def test_basic(self):
     c = Calendar()
     c = c.add(
         Day(date_=today, project_name="EPG Support", project_time="08:00"))
     c = c.add_project("EPG Support")
     s = ConsoleDayShower(c).show_days(today, 1)
     assert "EPG Support" in s
     assert "08:00" in s
Esempio n. 9
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
Esempio n. 10
0
 def _report_on_project_number(self):
     if len(self.args) > 2:
         raise UnexpectedOptionError(self.args[2:])
     self._validate_report_on_project_number(self.args)
     day = Day(
         date_=self.date,
         project_name=self._project_name(int(self.args[0])),
         project_time=self.args[-1],
     )
     return self.calendar.add(day)
Esempio n. 11
0
 def test_added(self):
     c = Calendar()
     wednesday = today + timedelta(days=-today.weekday() + 2)
     c = c.add(Day("came 8 left 18 lunch 45m", wednesday))
     s = ConsoleDayShower(c).show_days(today, 5)
     assert "08:00" in s
     assert "18:00" in s
     assert "0:45" in s
     assert "Came" in s
     assert "Left" in s
     assert "Lunch" in s
Esempio n. 12
0
 def test_basic(self):
     c = Calendar()
     c = c.add(
         Day(
             args="came 9 left 16:45 lunch 0m",
             date_=today,
             project_name="Parental leave",
             project_time="04:00",
         ))
     c = c.add_project("Parental leave", work=False)
     s = ConsoleDayShower(c).show_days(today, 1)
     assert "Parental leave" in s
     assert "04:00" in s
     assert "07:45" in s
Esempio n. 13
0
 def _report_on_project_name(self):
     if len(self.args) > 2:
         raise UnexpectedOptionError(self.args[2:])
     project_name = self.args[0]
     project_name_matches = self._project_name_matches(project_name)
     if not project_name_matches:
         raise ProjectNameDoesNotExistError(project_name)
     elif len(project_name_matches) > 1:
         raise AmbiguousProjectNameError(
             project_name, self._project_rows(project_name_matches))
     else:
         day = Day(
             date_=self.date,
             project_name=project_name_matches[0],
             project_time=self.args[-1],
         )
         return self.calendar.add(day)
Esempio n. 14
0
 def test_came_left_lunch(self):
     c = Calendar()
     c = c.add(Day("came 9 left 15 lunch 30m", today))
     assert "30" in ConsoleDayShower(c).show_days(today, 1)
     c, _ = c.undo()
     assert "30" not in ConsoleDayShower(c).show_days(today, 1)
Esempio n. 15
0
 def test_project(self):
     d = Day(project_name="EPG Support", project_time="08:00")
     assert d.projects["EPG Support"] == timedelta(hours=8)
Esempio n. 16
0
 def test_add_to_nothing(self):
     c = Calendar()
     c = c.add(Day("", today))
     c = c.add(Day("came 8 left 18 lunch 45m", today))
     assert c.days[today] == Day("came 8 left 18 lunch 45m", today)
Esempio n. 17
0
 def test_change_came_and_left(self):
     c = Calendar()
     c = c.add(Day("came 9 left 16 lunch 45m", today))
     c = c.add(Day("came 8 left 15", today))
     assert c.days[today] == Day("came 8 left 15 lunch 45m", today)
Esempio n. 18
0
 def test_overwrite_lunch(self):
     c = Calendar()
     c = c.add(Day("lunch 45m", today))
     c = c.add(Day("lunch 35m", today))
     assert c.days[today].lunch == timedelta(minutes=35)
Esempio n. 19
0
 def test_add_to_other_class_error(self):
     with pytest.raises(timereporter.day.DayAddError):
         Day() + 2
Esempio n. 20
0
 def test_error(self):
     with pytest.raises(TimeParserError):
         Day("came 9s3 left 15")
Esempio n. 21
0
 def test_basic(self):
     c = Calendar(target_hours_per_day=timedelta(hours=8.00))
     c = c.add(Day("came 9 left 18", today))
     s = ConsoleDayShower(c).show_days(today, 1)
     assert re.search("Flex *01:00", s)
Esempio n. 22
0
 def test_new_object_is_created(self):
     d1 = Day()
     d2 = Day()
     d3 = d1 + d2
     assert d3 is not d1
     assert d3 is not d2
Esempio n. 23
0
 def test_add_came_left_and_lunch_with_empty(self):
     d1 = Day()
     d2 = Day("came 9 left 17 lunch 45m")
     assert d1 + d2 == Day("came 9 left 17 lunch 45m")
Esempio n. 24
0
 def test_no_lunch(self):
     d = Day("came 09:00 left 15:00")
     assert str(d.came) == "09:00"
     assert str(d.left) == "15:00"
Esempio n. 25
0
 def test_whole_day_with_lunch(self):
     d = Day("came 9 left 15 lunch 45min")
     assert str(d.came) == "09:00"
     assert str(d.left) == "15:00"
     assert str(d.lunch) == "00:45"
Esempio n. 26
0
 def test_add_to_day_inverse_order(self):
     c = Calendar()
     c = c.add(Day("left 15", today))
     c = c.add(Day("came 9", today))
     assert c.days[today].came == time(9)
     assert c.days[today].left == time(15)
 def new_calendar(self, created_at: datetime.datetime) -> Calendar:
     day = Day(self.args, self.date, created_at=created_at)
     return self.calendar.add(day)
Esempio n. 28
0
 def test_overwrite_all(self):
     c = Calendar()
     c = c.add(Day("came 9 left 15", today))
     c = c.add(Day("came 8 left 14", today))
     assert c.days[today].came == time(8)
     assert c.days[today].left == time(14)
Esempio n. 29
0
 def test_add_day(self):
     c = Calendar()
     c = c.add(Day("came 9 left 15", today))
     assert c.days[today].came == time(9)
     assert c.days[today].left == time(15)
Esempio n. 30
0
 def test_day_fix_wrong_lunch_format(self):
     d = Day("lunch 01:00")
     assert d.lunch == timedelta(minutes=60)