コード例 #1
0
    def test_스케쥴_수정_2째줄로(self):  # Given
        # Given
        user_data = [[
            "hyunho", 0, ["2019-04-16 09:30:00", "2019-04-16 10:30:00"],
            ["2019-04-16 13:00:00", "2019-04-16 15:00:00"]
        ], ["hyunho", 1, ["2019-04-16 10:00:00", "2019-04-16 12:00:00"]]]
        origin_task = ["2019-04-16 09:30:00", "2019-04-16 10:30:00"]
        update_task = ["2019-04-16 09:30:00", "2019-04-16 15:30:00"]
        expected = [[
            "hyunho", 0, ["2019-04-16 09:30:00", "2019-04-16 15:30:00"]
        ],
                    [
                        "hyunho", 1,
                        ["2019-04-16 10:00:00", "2019-04-16 12:00:00"],
                        ["2019-04-16 13:00:00", "2019-04-16 15:00:00"]
                    ]]
        c = controller.Controller()

        # When
        result = c.update(user_data, origin_task, update_task)

        print(result)
        print(expected)
        # Then
        self.assertCountEqual(result[0], expected[0])
        self.assertCountEqual(result[1], expected[1])
コード例 #2
0
    def test_스케쥴_삽입_긴_줄(self):
        # Given
        user_data = [[
            "hyunho", 0, ["2019-04-16 09:30:00", "2019-04-16 10:30:00"],
            ["2019-04-16 13:00:00", "2019-04-16 15:00:00"]
        ], ["hyunho", 1, ["2019-04-16 10:00:00", "2019-04-16 12:00:00"]]]
        insert_data = ["2019-04-16 01:00:00", "2019-04-16 23:00:00"]
        expected = [
            ["hyunho", 0, ["2019-04-16 01:00:00", "2019-04-16 23:00:00"]],
            [
                "hyunho", 1, ["2019-04-16 10:00:00", "2019-04-16 12:00:00"],
                ["2019-04-16 13:00:00", "2019-04-16 15:00:00"]
            ], ["hyunho", 2, ["2019-04-16 09:30:00", "2019-04-16 10:30:00"]]
        ]
        username = "******"
        c = controller.Controller()

        # When
        result = c.insert(username, user_data, insert_data)

        print("expected", expected)
        print("result", result)

        # Then
        self.assertCountEqual(result[0], expected[0])
        self.assertCountEqual(result[1], expected[1])
        self.assertCountEqual(result[2], expected[2])
コード例 #3
0
    def test_일정길이(self):
        # Given
        single_task = ["2019-04-16 09:30:00", "2019-04-16 10:30:00"]
        c = controller.Controller()
        expected = 60

        # When
        time_length = c.get_time_length(single_task)

        # Then
        self.assertEqual(time_length, expected)
コード例 #4
0
    def test_스케쥴_삽입_처음(self):
        # Given
        user_data = []
        username = "******"
        insert_data = ["2019-04-16 11:00:00", "2019-04-16 12:00:00"]
        expected = [[
            "hyunho", 0, ["2019-04-16 11:00:00", "2019-04-16 12:00:00"]
        ]]
        c = controller.Controller()

        # When
        result = c.insert(username, user_data, insert_data)

        # Then
        self.assertEqual(result, expected)
コード例 #5
0
    def test_스케쥴_삽입_불가능(self):
        # Given
        user_data = [
            'hyunho', 0, ['2019-04-16 10:00:00', '2019-04-16 12:00:00'],
            ['2019-04-16 13:00:00', '2019-04-16 15:00:00']
        ]
        insert_data = ['2019-04-16 09:30:00', '2019-04-16 10:30:00']
        expected = False
        c = controller.Controller()

        # When
        result = c.is_task_insert_able(user_data, insert_data)

        # Then
        self.assertEqual(result, expected)
コード例 #6
0
    def test_스케쥴_삽입가능(self):
        # Given
        user_data = [
            "hyunho", 0, ["2019-04-16 09:30:00", "2019-04-16 10:30:00"],
            ["2019-04-16 13:00:00", "2019-04-16 15:00:00"]
        ]
        insert_data = ["2019-04-16 11:00:00", "2019-04-16 12:00:00"]
        expected = True
        c = controller.Controller()

        # When
        result = c.is_task_insert_able(user_data, insert_data)

        # Then
        self.assertEqual(result, expected)
コード例 #7
0
    def test_일정_삭제(self):
        # Given
        user_data = [[
            "hyunho", 0, ["2019-04-16 09:30", "2019-04-16 10:30"],
            ["2019-04-16 13:00", "2019-04-16 15:00"]
        ], ["hyunho", 1, ["2019-04-16 10:00", "2019-04-16 12:00"]]]
        remove_target_task = ["2019-04-16 09:30", "2019-04-16 10:30"]
        expected = [["hyunho", 0, ["2019-04-16 13:00", "2019-04-16 15:00"]],
                    ["hyunho", 1, ["2019-04-16 10:00", "2019-04-16 12:00"]]]
        c = controller.Controller()
        # When
        result = c.remove_task(user_data, remove_target_task)

        # Then
        self.assertEqual(result, expected)
コード例 #8
0
    def test_테스크_삽입(self):
        # Given
        username = "******"
        start_time = '2019-04-16 10:00'
        end_time = '2019-04-16 13:00'
        task = [start_time, end_time]
        c = controller.Controller()

        # When
        c.insert_to_db(task)

        # Then
        t = Task.objects.get(username=username)
        print(t.username, t.task_start, t.task_end)
        self.assertEqual(t.username, "hyunho")
        self.assertEqual(t.task_start, '2019-04-16 10:00')
        self.assertEqual(t.end_time, '2019-04-16 13:00')
コード例 #9
0
    def test_스케쥴_삽입_2번째_줄(self):
        # Given
        user_data = [[
            "hyunho", 0, ["2019-04-16 09:30:00", "2019-04-16 10:30:00"],
            ["2019-04-16 13:00:00", "2019-04-16 15:00:00"]
        ]]
        insert_data = ["2019-04-16 10:00:00", "2019-04-16 12:00:00"]
        expected = [[
            "hyunho", 0, ["2019-04-16 10:00:00", "2019-04-16 12:00:00"],
            ["2019-04-16 13:00:00", "2019-04-16 15:00:00"]
        ], ["hyunho", 1, ["2019-04-16 09:30:00", "2019-04-16 10:30:00"]]]
        username = "******"
        c = controller.Controller()

        # When
        result = c.insert(username, user_data, insert_data)
        # Then
        self.assertCountEqual(result, expected)
コード例 #10
0
def select_userdata(name):
    c = controller.Controller()

    try:
        user_datas = Task.objects.filter(username=name)
        temp_data = []
        for item in user_datas:
            temp_task = []
            temp_task.append(str(item.task_start))
            temp_task.append(str(item.task_end))
            print("temp_task", temp_task)
            # temp_data.append(c.insert(item.username, temp_data, temp_task))
            temp_data = c.insert(item.username, temp_data, temp_task)
            print("temp_data", temp_data)
            print(item.task_start, item.task_end)
        return temp_data
    except ObjectDoesNotExist:
        empty_list = []
        return empty_list
コード例 #11
0
    def test_스케쥴_수정_1째줄(self):
        # Given
        user_data = [[
            "hyunho", 0, ["2019-04-16 09:30:00", "2019-04-16 10:30:00"],
            ["2019-04-16 13:00:00", "2019-04-16 15:00:00"]
        ], ["hyunho", 1, ["2019-04-16 10:00:00", "2019-04-16 12:00:00"]]]
        origin_data = ["2019-04-16 09:30:00", "2019-04-16 10:30:00"]
        update_data = ["2019-04-16 09:30:00", "2019-04-16 11:30:00"]
        expected = [[
            "hyunho", 0, ["2019-04-16 09:30:00", "2019-04-16 11:30:00"],
            ["2019-04-16 13:00:00", "2019-04-16 15:00:00"]
        ], ["hyunho", 1, ["2019-04-16 10:00:00", "2019-04-16 12:00:00"]]]
        c = controller.Controller()

        # When
        result = c.update(user_data, origin_data, update_data)

        # Then
        self.assertCountEqual(result[0], expected[0])
コード例 #12
0
    def test_스케쥴_삽입_1번째_줄(self):
        # Given
        user_data = [[
            "hyunho", 0, ["2019-04-16 09:30:00", "2019-04-16 10:30:00"]
        ]]
        insert_data = ["2019-04-16 11:00:00", "2019-04-16 12:00:00"]
        expected = [[
            "hyunho", 0, ["2019-04-16 09:30:00", "2019-04-16 10:30:00"],
            ["2019-04-16 11:00:00", "2019-04-16 12:00:00"]
        ]]
        username = "******"
        temp = [[
            'hyunho', 0, ['2019-04-16 10:00:00', '2019-04-16 12:00:00'],
            ['2019-04-16 13:00:00', '2019-04-16 15:00:00']
        ]]
        c = controller.Controller()

        # When
        result = c.insert(username, user_data, insert_data)

        # Then
        self.assertCountEqual(result[0], expected[0])