def strict_inline_search(session): """Create several sticker sets and stickers with tags for strict sticker search testing.""" # Create a set with a 40 stickers, each having one tag `testtag` sticker_set_1 = sticker_set_factory(session, 'z_mega_awesome') for i in range(0, 40): # This is a little workaround to prevent fucky number sorting stuff if i < 10: i = f'0{i}' sticker = sticker_factory(session, f'sticker_{i}', ['testtag', 'unique_other']) sticker_set_1.stickers.append(sticker) # Create a second set with 20 stickers, each having one tag `testtag` as well sticker_set_2 = sticker_set_factory(session, 'a_dumb_shit') for i in range(40, 60): sticker = sticker_factory(session, f'sticker_{i}', ['testtag', 'roflcopter']) sticker_set_2.stickers.append(sticker) session.commit() # # Debugg stuff # print(sticker_set_1) # for sticker in sticker_set_1.stickers: # print(sticker) # print(sticker_set_2) # for sticker in sticker_set_2.stickers: # print(sticker) return [sticker_set_1, sticker_set_2]
def strict_inline_search(session): """Create several sticker sets and stickers with tags for strict sticker search testing.""" # Create a set with a 40 stickers, each having one tag `testtag` sticker_set_1 = sticker_set_factory(session, "z_mega_awesome") for i in range(0, 40): # This is a little workaround to prevent fucky number sorting stuff if i < 10: i = f"0{i}" sticker = sticker_factory(session, f"sticker_{i}", ["testtag", "unique-other"]) sticker_set_1.stickers.append(sticker) # Create a second set with 20 stickers, each having one tag `testtag` as well sticker_set_2 = sticker_set_factory(session, "a_dumb_shit") for i in range(40, 60): sticker = sticker_factory(session, f"sticker_{i}", ["testtag", "roflcopter"]) sticker_set_2.stickers.append(sticker) session.commit() return [sticker_set_1, sticker_set_2]
def fuzzy_inline_search(session): """Create several sticker sets and stickers with tags for strict sticker search testing.""" # Create a set with a 40 stickers, each having one tag `testtag` sticker_set_1 = sticker_set_factory(session, 'z_one_set') for i in range(0, 20): # This is a little workaround to prevent fucky number sorting stuff if i < 10: i = f'0{i}' sticker = sticker_factory(session, f'sticker_{i}', ['longstring', '/longstring']) sticker_set_1.stickers.append(sticker) # Create a second set with 20 stickers, each having one tag `testtag` as well sticker_set_2 = sticker_set_factory(session, 'a_another_one') for i in range(20, 40): sticker = sticker_factory(session, f'sticker_{i}', ['testtag', 'roflcopter']) sticker_set_2.stickers.append(sticker) session.commit() return [sticker_set_1, sticker_set_2]
def test_no_combined_on_full_strict(session, strict_inline_search, user): """Test fuzzy search for stickers.""" context = Context('roflcpter unique_other', '', user) # Add ten more stickers to the strict matching set sticker_set = strict_inline_search[0] for i in range(60, 70): sticker = sticker_factory(session, f'sticker_{i}', ['testtag', 'unique_other']) sticker_set.stickers.append(sticker) session.commit() matching_stickers, fuzzy_matching_stickers, duration = get_matching_stickers(session, context) # Context properties have been properly set assert not context.switched_to_fuzzy assert context.limit is None assert context.fuzzy_offset is None # Sticker result counts are correct assert len(matching_stickers) == 50 assert len(fuzzy_matching_stickers) == 0