Пример #1
0
def test_view_model_can_show_todo_items():
    items = [
        TodoItem("1", "To Do", "New Todo"),
        TodoItem("2", "Doing", "New Doing"),
        TodoItem("3", "Done", "New Done")
    ]

    view_model = ViewModel(items)

    todo_items = view_model.todo
    doing_items = view_model.doing
    done_items = view_model.done

    assert len(todo_items) == 1

    todo_item = todo_items[0]

    assert todo_item.id == "1"
    assert todo_item.status == "To Do"
    assert todo_item.title == "New Todo"

    assert doing_items[0].id == "2"
    assert doing_items[0].status == "Doing"
    assert doing_items[0].title == "New Doing"

    assert done_items[0].id == "3"
    assert done_items[0].status == "Done"
    assert done_items[0].title == "New Done"
Пример #2
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"
Пример #3
0
def test_recent_done_items():
    items = [
        TodoItem("1", "Done", "Recent Done", datetime.now()),
        TodoItem("2", "Done", "Old Done",
                 datetime.now() - timedelta(days=1))
    ]

    view_model = ViewModel(items)

    recent_todos = view_model.recent_done_items

    assert len(recent_todos) == 1
Пример #4
0
 def index():
     raw_cards = trello_client.get_cards_for_board()
     todo_items = [
         TodoItem.from_raw_trello_card(card) for card in raw_cards
     ]
     item_view_model = ViewModel(todo_items)
     return render_template('index.html', view_model=item_view_model)
Пример #5
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
Пример #6
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
Пример #7
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)
Пример #8
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"
Пример #9
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"
Пример #10
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)