With web 2.0 components starting to make their way into enterprise applications, the need to test tagging engines is starting to become more common place. Part of this testing is going to likely involve some sort of limits testing. So what if your limit is 50? 100? 1000? Are you going to type each of these in by hand? Not likely.
Toolsmith skills to the rescue. Here is a script which will generate a configurable amount of random length gibberish tags.
import string, random # how many words (min) MIN_WORDS = 1 # how many word (max) MAX_WORDS = 1000 # how many letters (min) MIN_LETTERS = 1 # hor many letters (max) MAX_LETTERS = 15 wordlist = [] for x in xrange(MIN_WORDS, MAX_WORDS): length = random.randint(MIN_LETTERS, MAX_LETTERS) word = [] for l in xrange(0, length): word.append(random.choice(string.ascii_letters)) wordlist.append("".join(word)) print ",".join(wordlist)
Now clearly, it could be improved. Two things off the top of my head would be
- to choose random real words from a scrabble dictionary (there are a couple available online if you look)
- if your tags are associated with things like images or blog posts, then you could generate the list which you randomly select from off of the existing tags for full contextual relevance
Like most things produced to aid testing, it doesn’t have to look nice, just be effective. And it was.