def salvar(_handler, _usuario_corrente, nome, descricao): from web.curso.home import index curso = Curso(nome=nome, descricao=descricao, dono_key=_usuario_corrente.key) curso.put() path = router.to_path(index) _handler.redirect(path)
def test_sucesso(self): usuario_logado = Usuario() usuario_logado.put() curso = Curso(nome="PyPratico", dono_key=usuario_logado.key) curso.put() resposta_mock = Mock() rest.listar_cursos(resposta_mock, usuario_logado) lista_dct = [{"id": curso.key.id(), "nome": curso.nome}] json_str = json.dumps(lista_dct) resposta_mock.write.assert_called_once_with(json_str)
def test_sucesso(self): usuario_logado = Usuario() usuario_logado.put() curso = Curso(nome='PyPratico', dono_key=usuario_logado.key) curso.put() resposta_mock = Mock() rest.listar_cursos(resposta_mock, usuario_logado) lista_dct = [{'id': curso.key.id(), 'nome': curso.nome}] json_str = json.dumps(lista_dct) resposta_mock.write.assert_called_once_with(json_str)
def salvar_curso(_resp, _usuario_corrente, nome, descricao): curso = Curso(dono_key=_usuario_corrente.key, nome=nome, descricao=descricao) key = curso.put() json_str = json.dumps({'id': key.id()}) _resp.write(json_str)
def test_sucesso(self): write_mock = Mock() curso = Curso(nome='Foo') chave = curso.put() crud.detalhar(write_mock, str(chave.id())) write_mock.assert_called_once_with('curso_detalhe.html', {'curso': curso}) tmpl.render('curso_detalhe.html', {'curso': curso,'_path':'/'})
def test_sucesso(self): write_mock = Mock() curso = Curso(nome='Foo') chave = curso.put() crud.detalhar(write_mock, str(chave.id())) write_mock.assert_called_once_with('curso_detalhe.html', {'curso': curso}) tmpl.render('curso_detalhe.html', {'curso': curso, '_path': '/'})