def index(): """The main page of the application""" flask.g.vocab = WORDS.as_list() flask.session["target_count"] = min(len(flask.g.vocab), CONFIG.SUCCESS_AT_COUNT) flask.session["jumble"] = jumbled(flask.g.vocab, flask.session["target_count"]) flask.session["matches"] = [] app.logger.debug("Session variables have been set") assert flask.session["matches"] == [] assert flask.session["target_count"] > 0 app.logger.debug("At least one seems to be set correctly") return flask.render_template('vocab.html')
def getinfo(): # Set the variables target = min(len(WORDS.as_list()), CONFIG.SUCCESS_AT_COUNT) global letters_to_use letters_to_use = jumbled(WORDS.as_list(), target) # Format them into a dict, and return as json info = {} info['target'] = target # Target number of words to find info['letters'] = letters_to_use # Letters they can use word_list = WORDS.as_list() info['words'] = word_list # A list of the words return flask.jsonify(info)
def test_jumbled_pair(): assert same(jumbled(["abbc", "abcc"], 2), "abbcc")
def test_jumbled_more(): assert same(jumbled(["aabc", "abac", "bcaa"], 2), "aabc")
def test_jumbled_single(): assert same(jumbled(["abbcd"], 1), "abbcd")