def mock_get_items(collection): items = [ Card( "60d459cb5781dcb66dab942b", "Done", "Exercise 9", "2021-06-24T21:29:29.569+00:00" ), Card( "60d459cb5781dcb66dab942b", "Doing", "Test Doing", "2021-06-24T21:29:29.569+00:00" ), Card( "60d459cb5781dcb66dab942b", "Done", "Test", "2021-06-24T22:26:03.415+00:00" ), Card( "60d459cb5781dcb66dab942b", "Done", "Test Done", "2021-06-24T10:32:45.385+00:00"), Card( "60d459cb5781sdf66dab942b", "ToDo", "Test Todo", "2021-06-30T09:18:13.037+00:00" ) ] return items
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
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"
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 get_items(collection): items = [] for item in collection.find(): items.append( Card(item['_id'], item['status'], item['title'], item['last_modified'])) return items
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"
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))
def card_details(self, data): db_cards = [] for item in data: card_id = item['id'] card_name = item['name'] if item['idList'] == "ToDo": card_status = "ToDo" elif item['idList'] == "Doing": card_status = "Doing" else: card_status = "Done" card_mod_date = item['dateLastActivity'] card = Card(card_id, card_name, card_status, card_mod_date) db_cards.append(card) return db_cards
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
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 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)