def test_success(self): self.assertIsNone(Course.query().get()) redirect_response = save(nome='nome_string') self.assertIsInstance(redirect_response, RedirectResponse) saved_course = Course.query().get() self.assertIsNotNone(saved_course) self.assertEquals('nome_string', saved_course.nome)
def test_error(self): template_response = save() errors = template_response.context['errors'] self.assertSetEqual(set(['nome']), set(errors.keys())) self.assert_can_render(template_response)
def test_falha(self): resposta = new.save(nome='') self.assertIsInstance(resposta, TemplateResponse) self.assert_can_render(resposta) self.assertDictEqual({'nome': u'Required field'}, resposta.context['errors'])
def test_sucesso(self): resposta = new.save(nome='App Engine') self.assertIsInstance(resposta, RedirectResponse) curso = Course.query().get() self.assertIsNotNone(curso) self.assertEqual('App Engine', curso.nome)