def test_older_done_items(): today = datetime.today() items = [ Item(dummy_id, dummy_title, 'done-items', today + timedelta(days = -1)) ,Item(dummy_id, dummy_title, 'Status is not "done-items"', today + timedelta(days = -1)) ,Item(dummy_id, dummy_title, 'done-items', today) ] item_view_model = ItemViewModel(items) older_done_items = item_view_model.older_done_items assert older_done_items == [ Item(dummy_id, dummy_title, 'done-items', today + timedelta(days = -1)) ]
def test_done_items(): items = [ Item(dummy_id, dummy_title, 'done-items', dummy_last_modified) ,Item(dummy_id, dummy_title, 'Status is not "done-items"', dummy_last_modified) ,Item(dummy_id, dummy_title, 'done-items', dummy_last_modified) ] item_view_model = ItemViewModel(items) done_items = item_view_model.done_items assert done_items == [ Item(dummy_id, dummy_title, 'done-items', dummy_last_modified) ,Item(dummy_id, dummy_title, 'done-items', dummy_last_modified) ] empty_items = [] empty_item_view_model = ItemViewModel(empty_items) empty_done_items = empty_item_view_model.done_items assert empty_done_items == []
def test_todo_items(): items = [ Item(dummy_id, dummy_title, 'todo-items', dummy_last_modified) ,Item(dummy_id, dummy_title, 'Status is not "todo-items"', dummy_last_modified) ,Item(dummy_id, dummy_title, 'todo-items', dummy_last_modified) ] item_view_model = ItemViewModel(items) todo_items = item_view_model.todo_items assert todo_items == [ Item(dummy_id, dummy_title, 'todo-items', dummy_last_modified) ,Item(dummy_id, dummy_title, 'todo-items', dummy_last_modified) ] empty_items = [] empty_item_view_model = ItemViewModel(empty_items) empty_todo_items = empty_item_view_model.todo_items assert empty_todo_items == []
def init_brand_and_category(self): Item.drop_collection() Brand.drop_collection() Category.drop_collection() DepartmentStore.drop_collection() department = DepartmentStore(name='Macys') department.save() brand = Brand(name=Name(en='Giani Bernini'), is_approved=True) brand.save() main = Category(name=Name(en="Handbags"), level=1, is_approved=True) main.save() sub = Category(name=Name(en="Satchels"), parent=main, level=2, is_approved=True) sub.save() main.sub_categories.append(sub) main.save()
def items(self): items = [] collections = self.db.list_collection_names() lists = [ collection for collection in collections if 'items' in collection ] for list in lists: raw_items = self.db[list].find() for raw_item in raw_items: item = Item(str(raw_item['_id']), raw_item['title'], list, raw_item['last_modified']) items.append(item) return items
def test_show_all_done_items(): items_x4 = [ Item(dummy_id, dummy_title, 'done-items', dummy_last_modified) ,Item(dummy_id, dummy_title, 'done-items', dummy_last_modified) ,Item(dummy_id, dummy_title, 'done-items', dummy_last_modified) ,Item(dummy_id, dummy_title, 'done-items', dummy_last_modified) ] item_view_model_x4 = ItemViewModel(items_x4) assert item_view_model_x4.show_all_done_items == True items_x5 = [ Item(dummy_id, dummy_title, 'done-items', dummy_last_modified) ,Item(dummy_id, dummy_title, 'done-items', dummy_last_modified) ,Item(dummy_id, dummy_title, 'done-items', dummy_last_modified) ,Item(dummy_id, dummy_title, 'done-items', dummy_last_modified) ,Item(dummy_id, dummy_title, 'done-items', dummy_last_modified) ] item_view_model_x5 = ItemViewModel(items_x5) assert item_view_model_x5.show_all_done_items == False
def init_im_item(self): self.init_item() self.init_imbrand_and_imcategory() set_usd_price() create_im_items(Item.objects(), Item.objects.count())