예제 #1
0
def test_no_filter():
    items = [Item("id1", "title1", "To Do"), Item("id2", "title2", "Done")]

    view_model = ViewModel(items)

    todo_items = view_model.get_items()

    assert len(todo_items) == 0
예제 #2
0
def test_doneitems():
    items = [
        Item(1, 'List saved todo items', 'To Do'),
        Item(2, 'List saved doing items', 'Doing'),
        Item(3, 'List saved completed items', 'Completed')
    ]

    view_model = ViewModel(items)

    assert len(view_model.completed_items()) == 1
예제 #3
0
def test_filtering_items():
    items = [Item("id1", "title1", "To Do"), Item("id2", "title2", "Done")]

    view_model = ViewModel(items)

    todo_items = view_model.get_items(["To Do"])

    assert len(todo_items) == 1

    todo_item = todo_items[0]

    assert todo_item.id == "id1"
    assert todo_item.title == "title1"
    assert todo_item.status == "To Do"
예제 #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_items_property():
    items = [
        Item("id1", "title1", "To Do"),
        Item("id2", "title2", "Doing"),
        Item("id3", "title3", "Done")
    ]

    view_model = ViewModel(items)

    all_items = view_model.items

    assert len(all_items) == 3

    todo_item_1 = all_items[0]

    assert todo_item_1.id == "id1"
    assert todo_item_1.title == "title1"
    assert todo_item_1.status == "To Do"

    doing_item_1 = all_items[1]

    assert doing_item_1.id == "id2"
    assert doing_item_1.title == "title2"
    assert doing_item_1.status == "Doing"

    done_item_1 = all_items[2]

    assert done_item_1.id == "id3"
    assert done_item_1.title == "title3"
    assert done_item_1.status == "Done"
예제 #6
0
 def index():
     raw_trello_cards = trello.get_cards(trello_config)
     items = [
         TodoItem.from_raw_trello_card(card) for card in raw_trello_cards
     ]
     item_view_model = ViewModel(items)
     return render_template('index.html', view_model=item_view_model)
예제 #7
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"
def test_show_all_done_items_property():
    cards = [
        Card(1, "New Done Item", "", "Done", datetime.now()),
        Card(2, "Old Done Item", "", "Done", datetime.now() - timedelta(days=7))
    ]
    view_model = ViewModel(cards)

    assert len(view_model.show_all_done_items) == 2
예제 #9
0
    def get_items():
        items = trello_cards.get_items()

        cards = []
        for item in items:
            card = Card.from_raw_trello_card(item)
            cards.append(card)

        return render_template('index.html', model=ViewModel(cards))
예제 #10
0
 def index():
     app.logger.info("Start rendering template for get call")
     app.logger.info(
         f'Env variables are {os.environ.get("MONGO_USER_NAME")}')
     cards = fetch_all_cards("To Do", "Doing", "Done")
     view_model_obj = ViewModel(cards)
     if app.config.get('LOGIN_DISABLED') or current_user.role == 'writer':
         user_role = 'writer'
     else:
         user_role = 'reader'
     app.logger.debug(f'Inside app.py - create_app() {view_model_obj}')
     app.logger.info("Rendering of the template follows...")
     return render_template(
         'index.html',
         todo_cards=view_model_obj.get_cards('To Do'),
         doing_cards=view_model_obj.get_cards('Doing'),
         done_cards=view_model_obj.return_all_done_cards(5),
         user_role=user_role)
예제 #11
0
def test_get_items_filters_out_other_types():
    items = [
        Item("id1", "title1", "To Do"),
        Item("id2", "title2", "Doing"),
        Item("id3", "title3", "Done")
    ]

    view_model = ViewModel(items)

    todo_items = view_model.get_items(["Doing"])

    assert len(todo_items) == 1

    todo_item_1 = todo_items[0]

    assert todo_item_1.id == "id2"
    assert todo_item_1.title == "title2"
    assert todo_item_1.status == "Doing"
def test_recent_done_items_property():
    cards = [
        Card(1, "New Done Item", "", "Done", datetime.now()),
        Card(2, "Old Done Item", "", "Done", datetime.now() - timedelta(days=7))
    ]
    view_model = ViewModel(cards)

    assert len(view_model.recent_done_items) == 1
    assert view_model.recent_done_items[0].name == "New Done Item"
def test_older_done_items_property():
    cards = [
        
        Card(1, "New Done Item", "", "Done", datetime.now()),
        Card(2, "Old Done Item", "", "Done", datetime.now() - timedelta(days=7))

    ]
    view_model = ViewModel(cards)

    assert view_model.older_done_items[1].name == "Old Done Item"
예제 #14
0
    def get_all_items():
        items = sorted(item_registry.get_items(), key=lambda item: item.status, reverse=True)
        item_view_model = ViewModel(items)
        status = request.args.get('status')
        switch = {
            "todo": item_view_model.to_do_items,
            "doing": item_view_model.doing_items,
            "done": item_view_model.done_items,
        }

        return json.dumps(sorted(switch.get(status, item_view_model.items), key=lambda item: item.status, reverse=True), cls=ItemEncoder)
예제 #15
0
def get_item_view_model():
    items = []
    items.append(Item('1', 'todo item 1', '', '1', 'To Do'))
    items.append(Item('2', 'todo item 2', '', '1', 'To Do'))
    items.append(Item('3', 'doing item 1', '', '2', 'Doing'))
    items.append(Item('4', 'doing item 2', '', '2', 'Doing'))
    items.append(Item('5', 'doing item 3', '', '2', 'Doing'))
    items.append(Item('6', 'done item 1', '', '3', 'Done'))
    print(items)

    yield ViewModel(items)
def view_model() -> ViewModel:
    items = [
        Item(1, 'Test to do', None, None, 'To Do'),
        Item(2, 'Test doing', None, None, 'Doing'),
        Item(3, 'Test doing II', None, None, 'Doing'),
        Item(4, 'Test done', None, None, 'Done'),
        Item(5, 'Test done II', None, None, 'Done'),
        Item(6, 'Test done III', None, None, 'Done')
    ]
    view_model = ViewModel(items)
    return view_model
예제 #17
0
def test_view_model_todo_items():
    items = [
        TodoItem(1, "To Do", "This is To Do Item"),
        TodoItem(2, "Doing", "This is Doing Item"),
        TodoItem(3, "Done", "This is Done")
    ]
    viewmodel = ViewModel(items)
    todoitems = viewmodel.todo_items

    assert len(todoitems) == 1
    item = todoitems[0]
    assert item.status == 'To Do'
예제 #18
0
def test_view_model_done_items():
    items = [
        TodoItem(1, "Done", "This is Done Item"),
        TodoItem(2, "To Do", "This is Doing Item"),
        TodoItem(3, "Doing", "This is Doing")
    ]
    viewmodel = ViewModel(items)
    doneitems = viewmodel.done_items

    assert len(doneitems) == 1
    item = doneitems[0]
    assert item.status == 'Done'
예제 #19
0
 def index():
     items = collection.find()
     cards = []
     for item in items:
         cards.append(
             Item(item['_id'], item['name'], item['description'],
                  item['due_date'].strftime('%d/%m/%Y'), item['status']))
     item_view_model = ViewModel(cards)
     return render_template('index.html',
                            view_model=item_view_model,
                            is_writer=is_writer(),
                            is_admin=is_admin())
예제 #20
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
def test_done_property():
    cards = [
        Card(2, "Done Item", "", "Done"),
        Card(1, "Doing Item", "", "Doing")
    ]
    view_model = ViewModel(cards)

    done_items = view_model.done_items

    assert len(done_items) == 1

    done_item = done_items[0]
    assert done_item.status == "Done"
def test_shows_todo_items():

    items = [
        Card(1, "ToDo", "First item", "2020-10-27"),
        Card(2, "Doing", "Second item", "2020-10-27"),
        Card(3, "Done", "Third item", "2020-10-27")
    ]

    view_model = ViewModel(items, False)

    todo_items = view_model.todo_items
    assert len(todo_items) == 1
    card = todo_items[0]
    assert card.status == "ToDo"
def test_older_done_items():

    items = [
        Card(1, "ToDo", "First item", "2020-10-27T22:02:07.091Z"),
        Card(2, "Doing", "Second item", "2020-10-28T22:02:07.091Z"),
        Card(3, "Done", "Third item", now),
        Card(4, "Done", "Fourth item", now),
        Card(5, "Done", "Fifth item", "2020-10-26T22:02:07.091Z"),
        Card(6, "Done", "Sixth item", "2020-10-26T22:02:07.091Z"),
        Card(7, "Done", "Seventh item", "2020-10-26T22:02:07.091Z"),
    ]

    view_model = ViewModel(items, False)
    older_done_items = view_model.older_done_items
    assert len(older_done_items) == 3
예제 #24
0
 def index():
     query_params = {
         "key": os.environ.get('API_KEY'),
         "token": os.environ.get('TOKEN_KEY')
     }
     url = f"https://api.trello.com/1/lists/{os.environ.get('TODO_LISTID')}/cards"
     app.logger.info(f"{url}")
     itemsresponse = requests.get(url, params=query_params).json()
     app.logger.info(f"{itemsresponse}")
     items = []
     for card in itemsresponse:
         myitem = Item.from_trello_card(card)
         items.append(myitem)
     view_model = ViewModel(items)
     return render_template('index.html', view_model=view_model)
def test_show_all_done_items():

    items = [
        Card(1, "ToDo", "First item", "2020-10-27"),
        Card(2, "Doing", "Second item", "2020-10-27"),
        Card(3, "Done", "Third item", "2020-10-27"),
        Card(4, "Done", "Fourth item", "2020-10-27"),
        Card(5, "Done", "Fifth item", "2020-10-27"),
        Card(6, "Done", "Sixth item", "2020-10-27"),
        Card(7, "Done", "Seventh item", "2020-10-27"),
    ]

    view_model = ViewModel(items, False)

    all_done_items = view_model.show_all_done_items
    assert len(all_done_items) == 5
def test_todo_property():
    # Setup
    cards = [
        Card(1, "Todo Item", "", "Todo"),
        Card(2, "Done Item", "", "Done")
    ]

    view_model = ViewModel(cards)

    # Act
    todo_items = view_model.todo_items

    # Assert
    assert len(todo_items) == 1

    todo_item = todo_items[0]
    assert todo_item.status == "Todo"
예제 #27
0
def test_done_items_property():
    items = [
        Item("id1", "title1", "To Do"),
        Item("id2", "title2", "Doing"),
        Item("id3", "title3", "Done")
    ]

    view_model = ViewModel(items)

    done_items = view_model.done_items

    assert len(done_items) == 1

    done_item_1 = done_items[0]

    assert done_item_1.id == "id3"
    assert done_item_1.title == "title3"
    assert done_item_1.status == "Done"
예제 #28
0
def test_to_do_items_property():
    items = [
        Item("id1", "title1", "To Do"),
        Item("id2", "title2", "Doing"),
        Item("id3", "title3", "Done")
    ]

    view_model = ViewModel(items)

    todo_items = view_model.to_do_items

    assert len(todo_items) == 1

    todo_item_1 = todo_items[0]

    assert todo_item_1.id == "id1"
    assert todo_item_1.title == "title1"
    assert todo_item_1.status == "To Do"
예제 #29
0
def view_model():
    file_path = find_dotenv(".env.test")
    load_dotenv(file_path, override=True)

    _DEFAULT_ITEMS = [
        {
            "idShort": 1,
            "idList": os.getenv("LIST_ID_NOT_STARTED"),
            "name": "To-Do items",
            "dateLastActivity": "2021-04-21T09:59:06.065Z",
        },
        {
            "idShort": 2,
            "idList": os.getenv("LIST_ID_IN_PROGRESS"),
            "name": "In Progress Items",
            "dateLastActivity": "2021-04-21T09:59:06.065Z",
        },
        {
            "idShort": 3,
            "idList": os.getenv("LIST_ID_DONE"),
            "name": "Recent Done Items",
            "dateLastActivity": "3000-04-21T09:59:06.065Z",
        },
        {
            "idShort": 4,
            "idList": os.getenv("LIST_ID_DONE"),
            "name": "Older Done Items",
            "dateLastActivity": "2000-04-21T09:59:06.065Z",
        },
    ]
    items = []
    for item in _DEFAULT_ITEMS:
        items.append(TodoItem(item))

    view_model = ViewModel(items)

    return view_model
예제 #30
0
    def index():
        items = session_items.get_items()
        item_view_model = ViewModel(items)

        return render_template("index.html", view_model=item_view_model)