def test_insert_empty_stickers(db, sample_stickerset): sticker_storage = storage.StickerStorage(db) sticker_storage.store(sample_stickerset, []) def gen_empty_stickers(): yield sticker_storage.store(sample_stickerset, gen_empty_stickers())
def collect_sample_stickers(bot, db, stickerset_name): """collect sample stickers to test database Arguments: db (Mongo DB) """ stickerset = model._get_stickerset(bot, stickerset_name) stickers = model._get_stickers(bot, stickerset_name) stge = storage.StickerStorage(db) stge.store(stickerset, stickers)
def test_storage(db, sample_stickerset, sample_stickers): sticker_storage = storage.StickerStorage(db) sticker_storage.store(sample_stickerset, sample_stickers) stickerset = next(sticker_storage.get_stickersets()) assert stickerset['name'] == sample_stickerset['name'] assert stickerset['title'] == sample_stickerset['title'] sticker = next(sticker_storage.get_stickers(stickerset['name'])) sample_sticker = sample_stickers[0] assert sticker['image_id'] == sample_sticker['image_id'] assert sticker['stickerset_name'] == sample_sticker['stickerset_name'] assert sticker['emoji'] == sample_sticker['emoji'] assert sticker['image'] == sample_sticker['image'] assert sticker['image_path'] == sample_sticker['image_path'] assert sticker['image_width'] == sample_sticker['image_width'] assert sticker['image_height'] == sample_sticker['image_height']
def storage_(db, sample_stickerset, sample_stickers): storage_ = storage.StickerStorage(db) storage_.store(sample_stickerset, sample_stickers) return storage_
def _get_storage(config=MalCollectorConfig): db = MongoClient(config.MONGO_CONFIG.HOST, config.MONGO_CONFIG.PORT)[config.MONGO_CONFIG.DB] return storage.StickerStorage(db)