def test_getDoneItems_showAllDoneItems(done_items):
    # given (gt5 done items, and _show_all_done_items has value of True)
    today_done_viewModel = ViewModel(done_items, statuses)
    today_done_viewModel.show_all_done_items = True

    # when
    today_done_items = today_done_viewModel.getDoneItems()

    # then
    assert len(today_done_items) == 5
def test_getDoneItems_lt5(done_items):
    # given (lt5 done items)
    lt5_done_items = done_items[:4]
    lt5_done_viewModel = ViewModel(lt5_done_items, statuses)

    # when
    items = lt5_done_viewModel.getDoneItems()

    # then
    assert len(items) == 4
def test_filterItemsByDoneDate_today(done_items):
    # given
    done_viewModel = ViewModel(done_items, statuses)

    # when
    results = done_viewModel.filterItemsByDoneDate(done_items,
                                                   datetime.date.today())

    # then
    assert len(results) == 1
    assert results[0].done == done_items[2].done
def test_getDoneItems_today(done_items):
    # given (gt5 done items, _show_all_done_items has default value of False, and item[2] was done today)
    today_done_viewModel = ViewModel(done_items, statuses)

    # when
    today_done_items = today_done_viewModel.getDoneItems()

    # then
    assert len(today_done_items) == 1
    assert today_done_items[0].done == done_items[2].done
    assert today_done_items[0].id == done_items[2].id
def test_filterItemsByDoneDate_yesterday(done_items):
    # given
    done_viewModel = ViewModel(done_items, statuses)

    # when
    yesterday = datetime.date.today() - datetime.timedelta(days=1)
    results = done_viewModel.filterItemsByDoneDate(done_items, yesterday)

    # then
    assert len(results) == 4
    assert results[0].done == done_items[0].done
    assert results[1].done == done_items[1].done
    assert results[2].done == done_items[3].done
    assert results[3].done == done_items[4].done
Beispiel #6
0
def test_reader_role():
    items = [
        Item(id=1, title='TDD Test', status='Doing'),
        Item(id=2, title='TDD Test', status='Doing'),
    ]
    current_user_role = ViewModel(items, 'reader').user_role
    assert current_user_role == 'reader'
def test_ViewModel_done_items(timed_card_example_eight):
    view_model_example = ViewModel(timed_card_example_eight)
    view_model_done = view_model_example.done_items
    assertation = True
    for i in view_model_done:
        if i.status != "Done":
            assertation = False
    assert assertation == True
Beispiel #8
0
 def index():
     global viewModel
     viewModel = ViewModel(*api.getItemData())
     return render_template(
         'index.html',
         viewModel=viewModel,
         isWriter=True if app.config.get("LOGIN_DISABLED") == "True" else
         current_user.isWriter)
Beispiel #9
0
def test_get_doing_items():
    items = [
        Item(id=1, title='TDD Test', status='Doing'),
        Item(id=2, title='TDD Test', status='Doing'),
    ]
    doing_items_list = ViewModel(items, 'writer').doing_items
    assert len(doing_items_list) > 0
    for item in doing_items_list:
        assert item.status == 'Doing'
Beispiel #10
0
def test_get_todo_items():
    items = [
        Item(id=1, title='TDD Test', status='Todo'),
        Item(id=2, title='TDD Test', status='Todo'),
    ]
    todo_items_list = ViewModel(items, 'writer').todo_items
    assert len(todo_items_list) > 0
    for item in todo_items_list:
        assert item.status == 'Todo'
Beispiel #11
0
 def get_cards():
     params = {
         "key": os.getenv("TRELLO_KEY"),
         "token": os.getenv("TRELLO_TOKEN")
     }
     cards_in_board = requests.get("https://api.trello.com/1/boards/" +
                                   os.getenv("TRELLO_BOARDID") + "/cards",
                                   params=params)
     cards_in_board = cards_in_board.json()
     cards = [ToDoCard.from_trello_card(card) for card in cards_in_board]
     view_model = ViewModel(cards)
     return render_template('trello.html', view_model=view_model)
def test_older_done_items():
    items = []
    items.append(ToDoItem(1, 'List saved todo items', '', None, None,  datetime.strftime((datetime.today()-timedelta(days=1)), "%Y-%m-%dT%H:%M:%S.%fZ"), 'Done'))
    view_model = ViewModel(items)
    done_items = view_model.older_done_items
    assert len(done_items) == 1
def test_recent_done_items():
    items = []
    items.append(ToDoItem(1, 'List saved todo items', '', None, None, datetime.today(), 'Done'))
    view_model = ViewModel(items)
    done_items = view_model.recent_done_items
    assert len(done_items) == 1
Beispiel #14
0
 def index():
     #Code that fetches all the TODO items from Trello board
     item_view_model = ViewModel(todoMongoService.get_items(),
                                 current_user.role)
     return render_template('index.html', view_model=item_view_model)
def viewModel():
    return ViewModel(items, statuses)
def test_todo_items():
    items = []
    items.append(ToDoItem(1, 'List saved todo items', '', None, None, datetime.today(), 'To Do'))
    view_model = ViewModel(items)
    todo_items = view_model.todo_items
    assert len(todo_items) == 1
def test_show_all_done_items_getter():
    items = []
    view_model = ViewModel(items)
    assert view_model.show_all_done_items == False
def test_ViewModel_status_done(timed_card_example_eight):
    view_model_example = ViewModel(timed_card_example_eight)
    len(view_model_example.done_items) == 6
def test_ViewModel_status_to_do(timed_card_example_eight):
    view_model_example = ViewModel(timed_card_example_eight)
    assert len(view_model_example.to_do_items) == 2
def test_simple_ViewModel_items(simple_test_items):
    simple_ViewModel_items = ViewModel(simple_test_items).items
    assert simple_ViewModel_items == simple_test_items
def test_show_all_done_items_setter():
    items = []
    view_model = ViewModel(items)
    view_model.show_all_done_items = True
    assert view_model.show_all_done_items == True
def test_ViewModel_recent_items(timed_card_example_eight):
    view_model_example = ViewModel(timed_card_example_eight)
    view_model_done_recent = view_model_example.recent_done_items
    assert len(view_model_done_recent) == 2
Beispiel #23
0
 def view():
     item_view_model = ViewModel(mongo.get_items())
     return render_template('/index.html', view_model=item_view_model)
def test_ViewModel_older_items(timed_card_example_eight):
    view_model_example = ViewModel(timed_card_example_eight)
    view_model_done_older = view_model_example.older_done_items
    assert len(view_model_done_older) == 4