Exemplo n.º 1
0
def test_number_of_done_items():
    card1 = make_card('id 1', 'name 1', '2021-02-14')
    card2 = make_card('id 2', 'name 2', '2021-02-15')

    done_list = {'name': 'Done', 'cards': [card1, card2]}

    vm = ViewModel([done_list])

    assert vm.count_done_items() == 2
Exemplo n.º 2
0
def test_view_model_show_todo_items():
    items = [
        Item(1, "New Todo", "To Do"),
        Item(2, "In Progress Todo", "Doing"),
        Item(3, "Completed", "Done"),
    ]
    view_model = ViewModel(items)

    todo_items = view_model.todo_items()

    assert len(todo_items) == 1

    todo_item = todo_items[0]

    assert todo_item.status == "To Do"
Exemplo n.º 3
0
def test_view_recent_done_items():
    # assert
    done = TodoItem("9876", "Done", "Test Title", date.today())
    items = [done]
    view_model = ViewModel(items=items)

    assert len(view_model.recent_done_items) == 1
def test_show_all_done_and_older_done_items():
    # Arrange
    items = [{
        'id': 1,
        'status': 'Doing',
        'title': 'List saved todo items'
    }, {
        'id': 2,
        'status': 'To Do',
        'title': 'Allow new items to be added'
    }, {
        'id': 3,
        'status': 'Done',
        'title': 'Task 1',
        'complete_date': 'Mon Dec 21 11:46:31 2020'
    }, {
        'id': 4,
        'status': 'Done',
        'title': 'Task 8',
        'complete_date': 'Mon Dec 20 11:46:31 2020'
    }]
    view_model = ViewModel.view_model_with_sorted_items(
        items, datetime(2020, 12, 21))

    # Act
    show_all_done_items = view_model.show_all_done
    count_all_done_items = len(show_all_done_items)
    older_done_items = view_model.older_done_items
    count_older_done_items = len(older_done_items)

    # Assert
    assert count_all_done_items == 2
    assert count_older_done_items == 0
Exemplo n.º 5
0
    def older_done_items():
        lists_on_board = api.get_lists()
        for aList in lists_on_board:
            aList['cards'] = api.get_cards_for_lists(aList['id'])
        view_model = ViewModel(lists_on_board)

        return render_template('older_done.html', view_model=view_model)
def test_just_the_done_items():
    # Arrange
    items = [{
        'id': 1,
        'status': 'Doing',
        'title': 'List saved todo items'
    }, {
        'id': 2,
        'status': 'To Do',
        'title': 'Allow new items to be added'
    }, {
        'id': 3,
        'status': 'Done',
        'title': 'Allow items to be updated',
        'complete_date': 'Mon Dec 21 11:46:31 2020'
    }]
    view_model = ViewModel.view_model_with_sorted_items(
        items, datetime(2020, 12, 21))

    # Act
    don_items = view_model.done

    # Assert
    assert len(don_items) == 1
    for item in don_items:
        assert item['status'] == "Done"
Exemplo n.º 7
0
def test_view_old_done_items():
    # assert
    done = TodoItem("9876", "Done", "Test Title", date.today() - timedelta(1))
    items = [done]
    view_model = ViewModel(items=items)

    assert len(view_model.older_done_items) == 1
Exemplo n.º 8
0
def test_view_done_model_less_than_five():
    # assert
    done = TodoItem("9876", "Done", "Test Title", date.today)
    items = [done]
    view_model = ViewModel(items=items)

    assert len(view_model.done_items) == 1
    assert (view_model.show_done_items == True)
Exemplo n.º 9
0
def test_view_done_model():
    # assert
    done = TodoItem("9876", "Done", "Test Title", date.today)
    items = [done]
    view_model = ViewModel(items=items)

    assert len(view_model.done_items) == 1
    assert view_model.done_items[0].status == "Done"
Exemplo n.º 10
0
def test_older_done_items():
    card1 = make_card('id 1', 'name 1', '2021-02-14T10:03:29.527Z')
    card2 = make_card('id 2', 'name 2', '2021-02-15T11:03:29.527Z')
    card3 = make_card('id 3', 'name 3', '2021-02-15T15:03:29.527Z')
    card4 = make_card('id 4', 'name 4', '2021-02-16T12:03:29.527Z')
    card5 = make_card('id 5', 'name 5', '2021-02-17T04:03:29.527Z')
    card6 = make_card('id 6', 'name 6', '2021-02-12T02:03:29.527Z')
    today = datetime.fromisoformat('2021-02-16').date()

    done_list = {
        'name': 'Done',
        'cards': [card1, card2, card3, card4, card5, card6]
    }

    vm = ViewModel([done_list])

    assert vm.older_done_items(today) == [card1, card2, card3, card6]
Exemplo n.º 11
0
def test_view_doing_model():
    # assert
    doing = TodoItem("5678", "Doing", "Test Title", date.today)
    items = [doing]
    view_model = ViewModel(items=items)

    assert len(view_model.doing_items) == 1
    assert view_model.doing_items[0].status == "Doing"
Exemplo n.º 12
0
def test_view_to_do_model():
    # assert
    todo = TodoItem("1234", "To Do", "Test Title", date.today)
    doing = TodoItem("1234", "Doing", "Test Title", date.today)
    items = [todo, doing]
    view_model = ViewModel(items=items)

    assert len(view_model.todo_items) == 1
    assert view_model.todo_items[0].status == "To Do"
Exemplo n.º 13
0
    def index():
        items = trelloitems.fetch_items(os.getenv('TODOID'), 'TODO ITEMS')
        items += trelloitems.fetch_items(os.getenv('PENDINGID'),
                                         'PENDING ITEMS')
        items += trelloitems.fetch_items(os.getenv('DONEID'), 'DONE ITEMS')

        ##return render_template('index.html',items=items)
        item_view_model = ViewModel(items)
        return render_template('index.html', view_model=item_view_model)
Exemplo n.º 14
0
def test_show_all_done_items():
    card1 = make_card('id 1', 'name 1')
    card2 = make_card('id 2', 'name 2')
    card3 = make_card('id 3', 'name 3')
    card4 = make_card('id 4', 'name 4')

    done_list = {'name': 'Done', 'cards': [card1, card2, card3, card4]}

    vm = ViewModel([done_list])

    assert vm.show_all_done_items == True

    card1 = make_card('id 1', 'name 1')
    card2 = make_card('id 2', 'name 2')
    card3 = make_card('id 3', 'name 3')
    card4 = make_card('id 4', 'name 4')
    card5 = make_card('id 5', 'name 5')

    done_list = {'name': 'Done', 'cards': [card1, card2, card3, card4, card5]}

    vm = ViewModel([done_list])

    assert vm.show_all_done_items == False
Exemplo n.º 15
0
def test_to_do_items():
    card1 = make_card('id 1', 'name 1')
    card2 = make_card('id 2', 'name 2')
    card3 = make_card('id 3', 'name 3')
    card4 = make_card('id 4', 'name 4')

    to_do_list = {'name': 'To Do', 'cards': [card1]}
    doing_list = {'name': 'In Progress', 'cards': [card2]}
    done_list = {'name': 'Done', 'cards': [card3]}
    any_list = {'name': 'ANY', 'cards': [card4]}

    vm = ViewModel([to_do_list, doing_list, done_list, any_list])

    assert vm.to_do_items == [card1]
    assert vm.doing_items == [card2]
    assert vm.done_items == [card3]
Exemplo n.º 16
0
    def index():
        board_id = os.getenv('TRELLO_BOARD_ID')
        items_response = requests.get(
            f'https://api.trello.com/1/boards/{board_id}/cards',
            params={
                'key': os.getenv('TRELLO_KEY'),
                'token': os.getenv('TRELLO_TOKEN')
            })
        items_list = items_response.json()

        cards = []
        for item in items_list:
            new_card = Card(item["id"], item["name"], item["idList"])
            cards.append(new_card)

        # change to view model class - unit test
        view_model = ViewModel(cards)

        return render_template('index.html', view_model=view_model)
def test_just_the_todo_items():
    # Arrange
    items = [{
        'id': 1,
        'status': 'Doing',
        'title': 'List saved todo items'
    }, {
        'id': 2,
        'status': 'To Do',
        'title': 'Allow new items to be added'
    }]
    view_model = ViewModel(items)

    # Act
    todo_items = view_model.todo

    # Assert
    assert len(todo_items) == 1
    for item in todo_items:
        assert item['status'] == "To Do"
Exemplo n.º 18
0
    def index():
        url = f"https://api.trello.com/1/boards/{os.environ.get('TRELLO_BOARD_ID')}/cards"

        query = {
            'key': os.environ.get("TRELLO_KEY"),
            'token': os.environ.get("TRELLO_TOKEN")
        }

        response = requests.request("GET", url, params=query)

        #list of cards
        trello_cards = response.json()
        todo_items = []  # List of TodoItem

        for card in trello_cards:
            item = TodoItem.from_trello_card(card)
            todo_items.append(item)

        view_model = ViewModel(todo_items)

        return render_template('index.html', view_model=view_model)
def test_show_older_done_items():
    # Arrange
    items = [{
        'id': 1,
        'status': 'Doing',
        'title': 'List saved todo items'
    }, {
        'id': 2,
        'status': 'To Do',
        'title': 'Allow new items to be added'
    }, {
        'id': 3,
        'status': 'Done',
        'title': 'Task 1',
        'complete_date': 'Mon Dec 21 11:46:31 2020'
    }, {
        'id': 4,
        'status': 'Done',
        'title': 'Task 2',
        'complete_date': 'Mon Dec 21 11:56:31 2020'
    }, {
        'id': 5,
        'status': 'Done',
        'title': 'Task 3',
        'complete_date': 'Mon Dec 21 12:46:31 2020'
    }, {
        'id': 6,
        'status': 'Done',
        'title': 'Task 4',
        'complete_date': 'Mon Dec 21 9:46:31 2020'
    }, {
        'id': 7,
        'status': 'Done',
        'title': 'Task 5',
        'complete_date': 'Mon Dec 21 14:46:31 2020'
    }, {
        'id': 8,
        'status': 'Done',
        'title': 'Task 6',
        'complete_date': 'Mon Dec 21 15:46:31 2020'
    }, {
        'id': 9,
        'status': 'Done',
        'title': 'Task 7',
        'complete_date': 'Mon Dec 21 10:10:31 2020'
    }, {
        'id': 10,
        'status': 'Done',
        'title': 'Task 8',
        'complete_date': 'Mon Dec 20 11:46:31 2020'
    }]
    view_model = ViewModel.view_model_with_sorted_items(
        items, datetime(2020, 12, 21))
    id_of_old_items = [10]

    # Act
    older_done_items = view_model.older_done_items

    # Assert
    assert len(older_done_items) == 1
    for item in older_done_items:
        assert item['id'] in id_of_old_items
Exemplo n.º 20
0
 def index():
     items = Items().get_items
     item_view_model = ViewModel.view_model_with_sorted_items(items)
     return render_template('index.html', view_model=item_view_model)
Exemplo n.º 21
0
def test_empty_items():
    vm = ViewModel([])

    assert vm.to_do_items == []
    assert vm.doing_items == []
    assert vm.done_items == []