def test_get_joke_list(self): joke_list = jokefacade.get_teller_jokes(self.teller.username) self.assertNotEqual(0, len(joke_list)) last_date = None for joke in joke_list: self.assertNotEqual('', joke.value, "Joke can\' be empty!!") if last_date != None: self.assertTrue(last_date > joke.date_created, '%s should be after %s'%(str(last_date), str(joke.date_created))) last_date = joke.date_created
def get(request): if request.method == "POST": params = request.POST else: params = request.GET teller_username = params["jokeTeller"] is_owner = request.user.is_authenticated() and request.user.username == teller_username return HttpResponse( simplejson.dumps( map( extract_joke, jokefacade.get_teller_jokes(teller_username, only_sent = not is_owner))))
def test_create_new_joke(self): joke_text = JOKE_4 new_joke = jokefacade.add_new_joke(self.teller.username, joke_text) self.assertNotEqual(None, new_joke, "New joke not created properly") new_joke_list = jokefacade.get_teller_jokes(self.teller.username, only_sent=False) self.assertTrue(new_joke in new_joke_list, "New joke not added to teller list")