示例#1
0
    def test_status_finished(self):
        actions = A().finish().done()
        self.actions_to_return(actions)

        self.handle(["status"])

        self.om.emmit.assert_called_once_with("test_project/finished")
示例#2
0
    def test_two_work_intervals(self):
        actions = (A().start().at(second=0).finish().at(second=10).start().at(
            second=20).finish().at(second=30).done())

        value = call(actions, test_config)

        self.assertEqual(value, 20)
示例#3
0
    def test_overtime(self):
        actions = (A().start().at(hour=0,
                                  second=0).finish().at(hour=1,
                                                        second=10).done())

        value = call(actions, test_config)

        self.assertEqual(value, -10)
示例#4
0
    def test_one_work_interval(self):
        actions = (A()
            .start().at(second=0)
            .finish().at(second=10)
            .done())

        value = call(actions, get_config())

        self.assertEqual(value, 10)
示例#5
0
    def test_today_started(self):
        self.now_to_return(hour=14, minute=15, second=16)
        actions = A().start().at(hour=8).done()
        self.actions_to_return(actions)

        self.handle(["today"])

        self.om.emmit.assert_called_once_with(
            "test_project/started/06:15:16/01:44:44")
示例#6
0
    def test_today_started_overtime(self):
        self.now_to_return(hour=16, minute=17, second=18)
        actions = A().start().at(hour=8).done()
        self.actions_to_return(actions)

        self.handle(["today"])

        self.om.emmit.assert_called_once_with(
            "test_project/started/08:17:18/-00:17:18")
示例#7
0
    def test_total_started(self):
        self.now_to_return(hour=19, minute=33, second=42)
        actions = A().start().at(hour=9).done()
        self.actions_to_return(actions)

        self.handle(["total"])

        self.om.emmit.assert_called_once_with(
            "test_project/started/10:33:42/29:26:18")
示例#8
0
    def test_total_started_overtime(self):
        self.now_to_return(day=3, hour=3, minute=4, second=5)
        actions = A().start().at(day=1, hour=8).done()
        self.actions_to_return(actions)

        self.handle(["total"])

        self.om.emmit.assert_called_once_with(
            "test_project/started/43:04:05/-03:04:05")
示例#9
0
    def test_all_started(self):
        self.now_to_return(hour=12, minute=34, second=56)
        actions = A().start().at(hour=8).done()
        self.actions_to_return(actions)

        self.handle(["all"])

        self.om.emmit.assert_called_once_with(
            "test_project/started/04:34:56/03:25:04/04:34:56/35:25:04")
示例#10
0
    def test_all_started_today_overtime(self):
        self.now_to_return(day=1, hour=9, minute=8, second=7)
        actions = A().start().at().done()
        self.actions_to_return(actions)

        self.handle(["all"])

        self.om.emmit.assert_called_once_with(
            "test_project/started/09:08:07/-01:08:07/09:08:07/30:51:53")
示例#11
0
    def test_work_almost_24h(self):
        actions = (A().start().at(hour=0, minute=0,
                                  second=0).finish().at(hour=23,
                                                        minute=59,
                                                        second=59).done())

        value = call(actions, test_config)

        self.assertEqual(value, 86399)
示例#12
0
    def test_work_24h(self):
        actions = (A().start().at(day=1, hour=0, minute=0,
                                  second=0).finish().at(day=2,
                                                        hour=0,
                                                        minute=0,
                                                        second=0).done())

        value = call(actions, test_config)

        self.assertEqual(value, 86400)
示例#13
0
    def test_two_work_intervals(self):
        actions = (A().start().at(day=1, second=0).finish().at(
            day=1,
            second=10).start().at(day=2,
                                  second=0).finish().at(day=2,
                                                        second=10).done())

        value = call(actions, test_config)

        self.assertEqual(value, ["2021-01-01", "2021-01-02"])
示例#14
0
    def test_all_finished_total_overtime(self):
        actions = (A().start().at(day=1, hour=0).finish().at(
            day=1, hour=23).start().at(day=2,
                                       hour=0).finish().at(day=2,
                                                           hour=23).done())
        self.actions_to_return(actions)

        self.handle(["all"])

        self.om.emmit.assert_called_once_with(
            "test_project/finished/23:00:00/-15:00:00/46:00:00/-06:00:00")
    def test_three_days(self):
        test_day = 2

        actions = (A().start().at(day=1, second=0).finish().at(
            day=1, second=10).start().at(day=2, second=0).finish().at(
                day=2,
                second=10).start().at(day=3,
                                      second=0).finish().at(day=3,
                                                            second=10).done())

        value = call(actions, get_config(day=test_day))

        self.assertEqual(value, 3590)
示例#16
0
    def test_start_action_type(self):
        actions = A().start().at().done()

        value = call(actions, test_config)

        self.assertEqual(value, 0)
示例#17
0
    def test_default_action_type(self):
        actions = A().test().done()

        value = call(actions)

        self.assertEqual(value, None)
示例#18
0
    def test_only_start_action(self):
        actions = A().start().done()

        value = call(actions)

        self.assertEqual(value, Actions.START)
示例#19
0
    def test_two_intervals(self):
        actions = A().start().finish().start().finish().done()

        value = call(actions)

        self.assertEqual(value, Actions.FINISH)
示例#20
0
    def test_default_action_type(self):
        actions = A().test().at().done()

        value = call(actions, test_config)

        self.assertEqual(value, [])
示例#21
0
    def test_one_start_at(self):
        expected = [Action(Actions.START, datetime(2021, 1, 1, 12, 34, 56))]

        actual = A().start().at(hour=12, minute=34, second=56).done()

        self.assertEqual(actual, expected)
示例#22
0
    def test_start_and_finish(self):
        expected = [Action(Actions.START, None), Action(Actions.FINISH, None)]

        actual = A().start().finish().done()

        self.assertEqual(actual, expected)
示例#23
0
    def test_one_start(self):
        expected = [Action(Actions.START, None)]

        actual = A().start().done()

        self.assertEqual(actual, expected)