def test_success_response(app_context): data = { 'test1': 123, 'test2': 'testing', 'test3': 123.123 } expected1 = { 'status': 'success' } expected1.update(data) expected2 = {'status': 'success'} expected3 = {'status': 'error'} assert expected1 == success_response(data).get_json() assert expected2 == success_response().get_json() assert expected3 != success_response().get_json()
def apiCadastroUsuario(): r = request.get_json() success, message = cadastroUsuario(r) if success: return success_response() else: return error_response(message)
def apiCadastroComentario(): r = request.get_json() id_disciplina = r.get('id_disciplina') comentario = r.get('comentario') id_user = session.get('id') success, message = cadastroComentario(id_user, id_disciplina, comentario) if success: return success_response() else: return error_response(message)
def apiUsuario(): logged_in = session.get('logged_in') if logged_in: data = { "username": session.get('username'), "name": session.get('name'), "email": session.get('email'), "profile_picture": session.get('profile_picture') } return success_response(data) else: return error_response("no user logged")
def apiCadastroLink(): r = request.get_json() id_disciplina = r.get('id_disciplina') titulo = r.get('titulo') link = r.get('link') id_user = session.get('id') success, message = cadastroLink(id_user, id_disciplina, titulo, link) if success: return success_response() else: return error_response(message)
def apiCadastroDisciplina(): r = request.get_json() nome = r.get('nome') penoso_mamao = r.get('penoso_mamao') id_user = session.get('id') success, message = cadastroDisciplina(nome, penoso_mamao, id_user) if success: return success_response() else: return error_response(message)
def apiCadastroAvaliacaoComentario(): r = request.get_json() id_comentario = r.get('id_comentario') like_dislike = r.get('like_dislike') id_user = session.get('id') success, message = cadastroAvaliacaoComentario(id_comentario, like_dislike, id_user) if success: return success_response() else: return error_response(message)
def apiCadastroAvaliacaoDisciplina(): r = request.get_json() id_disciplina = r.get('id_disciplina') penoso_mamao = r.get('penoso_mamao') id_user = session.get('id') success, message = cadastroAvaliacaoDisciplina(penoso_mamao, id_disciplina, id_user) if success: return success_response() else: return error_response(message)
def apiLogin(): r = request.get_json() username = r.get('username') password = r.get('password') status, data = checkUsuario(username, password) if status: session['logged_in'] = True session['id'] = data['id'] session['username'] = username session['name'] = data['name'] session['email'] = data['email'] session['profile_picture'] = data['picture'] return success_response() else: return error_response('Usuario e/ou senha incorreta')
def apiLogout(): session.clear() return success_response()