def test_items():
    # given
    item1 = ToDoItem(1, "First task", Status.DONE, datetime.date(2020, 5, 22))
    item2 = ToDoItem(2, "Second task", Status.TODO, datetime.date(2020, 5, 22))
    items = [item1, item2]

    # when
    indexViewModel = IndexViewModel(items, False, False)

    # then
    assert indexViewModel.items == items
def test_show_all_done_items():
    # given
    item1 = ToDoItem(1, "First task", Status.TODO, datetime.date(2020, 5, 22))
    item2 = ToDoItem(2, "Second task", Status.DOING,
                     datetime.date(2020, 5, 22))
    item3 = ToDoItem(3, "Third task", Status.DONE, datetime.date(2020, 5, 22))

    items = [item1, item2, item3]

    # when
    indexViewModel = IndexViewModel(items, False, False)

    # then
    assert indexViewModel.show_all_done_items == False
def test_older_done_items():
    # given
    item1 = ToDoItem(
        1, "First task", Status.TODO,
        datetime.datetime.combine(datetime.date(2020, 5, 22),
                                  datetime.time(1, 0)))
    item2 = ToDoItem(
        2, "Second task", Status.DONE,
        datetime.datetime.combine(datetime.date(2020, 8, 26),
                                  datetime.time(1, 0)))
    item3 = ToDoItem(
        3, "Third task", Status.DONE,
        datetime.datetime.combine(datetime.date(2020, 9, 20),
                                  datetime.time(1, 0)))

    items = [item1, item2, item3]

    # when
    indexViewModel = IndexViewModel(items, False, False)

    # then
    assert indexViewModel.older_done_items == [item2]
コード例 #4
0
 def index():
     items = storage.get_items()
     index_view_model = IndexViewModel(items, False, flask_login.current_user.has_writer_role())
     return render_template('index.html', viewModel=index_view_model)