def memepie(): if 'meme' in request.values: meme = Meme(request.values['meme']) if meme.is_valid(): twitter = Twitter() parser = Parser() texts = twitter.get_sources(meme, 20) #from source import Source #texts = [Source("", "x is my middle name",""), Source("", "y is my middle name", ""), Source("", "x is my middle name","")] result = parser.collate_words(meme, texts) gchart = GChart() g.clean_query = meme.get_clean_meme() g.meme_exceptions = meme.get_exceptions() g.meme_parts = meme.get_parts() g.pie_data = gchart.generate_pie_data(result) #first_word_source_list = result.get_source_list(result.get_list()[0][0]) return render_template("memepie.htm") else: g.clean_query = meme.get_clean_meme() #our understanding of meme g.error_message = meme.get_problem() return render_template("error.htm")
def test_two_stars_is_invalid(self): m = Meme("* into *") self.assertFalse(m.is_valid()) self.assertEqual(m.get_problem(), "has too many wildcards (*)")
def test_invalid_meme_is_invalid(self): m = Meme("nothing here") self.assertFalse(m.is_valid()) self.assertEqual(m.get_problem(), "has no wildcard (*)")
def test_valid_meme_is_valid(self): m = Meme("all your * -base") self.assertTrue(m.is_valid())