def test_remove_memos(): """ remove_memos function should work. This also serves to clear out any test memos, so that none are left over after the nose test is run. """ collection.insert(TEST_MEMO.copy()) found = collection.find(TEST_MEMO.copy()) found2 = collection.find({"type": "dated_memo", "date": TEST_MEMO['date'], "text": "Nosetest2" }) ids = [] for cursor in (found, found2): for memo in cursor: ids.append(str(memo['_id'])) flask_main.remove_memos(ids) assert not collection.find_one(TEST_MEMO.copy()) assert not collection.find_one({"type": "dated_memo", "date": TEST_MEMO['date'], "text": "Nosetest2" })
def test_deletion(): memos = get_memos() id = memos[0]['_id'] #remove one entry from the collection remove_memos(id) #get number of entries left assert collection.count() == 2 id = memos[1]['_id'] #remove next remove_memos(id) assert collection.count() == 1 id = memos[2]['_id'] #remove next remove_memos(id) assert collection.count() == 0
def testDeletingMemos(self): removeIds = [] for record in flask_main.collection.find({"text":"Sample text"}): removeIds.append(str(record['_id'])) deleted = flask_main.remove_memos(removeIds)