def test_get_exclusion_words(self): for i in range(10): text, ws = utils.generate_random_text() exclusion_words = utils.get_exclusion_words(text) self.assertTrue( len(exclusion_words) < len(text.split()) and len(exclusion_words) > 0)
def add(): text = request.form["text"] words = request.form["words"] if not words: # autogenerate words words = " ".join(utils.get_exclusion_words(text)) print words else: for word in words.split(): if word not in text.split(): return jsonify({"status": "Invalid data - few words not found in data."}) token = utils.generate_token() db_add_text(text, words, token) return jsonify({"status": "Data added successfully"})
def test_get_exclusion_words(self): for i in range(10): text, ws = utils.generate_random_text() exclusion_words = utils.get_exclusion_words(text) self.assertTrue(len(exclusion_words) < len(text.split()) and len(exclusion_words) > 0)