Exemple #1
0
    def test_append_entries(self):
        runner = MagicMock()

        mattermost = MattermostNotifier(runner)
        mattermost.appendEntries([])
        mattermost.send()

        text = """Found entries in toggl: **0** (filtered: **0**)
Altogether you did not work today at all :cry:. Hope you ok?
"""

        runner.send.assert_called_with(text)
Exemple #2
0
    def test_append_entries_one(self):
        runner = MagicMock()

        mattermost = MattermostNotifier(runner)
        mattermost.appendEntries(
            [TogglEntry(None, 60, self.today, 777, "", self.redmine_config)])
        mattermost.send()

        text = """Found entries in toggl: **1** (filtered: **0**)
You worked almost less than 4 hours today (exactly 1 m), not every day is a perfect day, right? :smirk:.
Huh, not many entries. It means, you did only a couple of tasks, but did it right .. right? :open_mouth:
Ugh. Less than 25% of your work had redmine id. Not so good :cry:.
"""

        runner.send.assert_called_with(text)
Exemple #3
0
    def test_append_entries_two_one_with_redmine(self):
        runner = MagicMock()

        mattermost = MattermostNotifier(runner)
        mattermost.appendEntries([
            TogglEntry(None, 60, self.today, 776, "", self.redmine_config),
            TogglEntry(None, 60, self.today, 777, "#666 Hardwork",
                       self.redmine_config),
        ])
        mattermost.send()

        text = """Found entries in toggl: **2** (filtered: **1**)
You worked almost less than 4 hours today (exactly 2 m), not every day is a perfect day, right? :smirk:.
Huh, not many entries. It means, you did only a couple of tasks, but did it right .. right? :open_mouth:
It's gooood. A lot of today work had redmine id! Congrats :sunglasses:.

---
**Redmine summary**
You spent most time on:
- #666: 0.02 h
"""

        runner.send.assert_called_with(text)
Exemple #4
0
    def test_ignore_negative_duration(self):
        """
        Mattermost should ignore entries with negative durations (pending entries).

		From toggl docs:
           duration: time entry duration in seconds. If the time entry is currently running, the duration attribute contains a negative value, denoting the start
           of the time entry in seconds since epoch (Jan 1 1970). The correct duration can be calculated as current_time + duration, where current_time is the current
           time in seconds since epoch. (integer, required)
        """

        runner = MagicMock()

        mattermost = MattermostNotifier(runner)

        l = [
            TogglEntry(None, 3600, self.today, 777, "test #333",
                       self.redmine_config),
            TogglEntry(None, -300, self.today, 778, "test #334",
                       self.redmine_config),
        ]

        mattermost.appendEntries(l)
        mattermost.send()

        text = """Found entries in toggl: **2** (filtered: **1**)
You worked almost less than 4 hours today (exactly 1.00 h), not every day is a perfect day, right? :smirk:.
Huh, not many entries. It means, you did only a couple of tasks, but did it right .. right? :open_mouth:
It seems that more than 75% of your today work had redmine id! So .. you rock :rocket:!

---
**Redmine summary**
You spent most time on:
- #333: 1.0 h
"""

        runner.send.assert_called_with(text)