From 2454060058fc408357182217e510ad1db7c43fab Mon Sep 17 00:00:00 2001 From: Unknown Date: Thu, 22 Mar 2018 15:13:05 -0400 Subject: [PATCH] Revert "Tests Python" This reverts commit d8437439425fecdeed6d081fb0d5fa3c8dd0ad62. --- application/api/qa.py | 2 +- application/models/Questions.py | 4 ++-- test.py | 39 ++++++--------------------------- 3 files changed, 10 insertions(+), 35 deletions(-) diff --git a/application/api/qa.py b/application/api/qa.py index cd244dc..475a651 100644 --- a/application/api/qa.py +++ b/application/api/qa.py @@ -116,7 +116,7 @@ def questionsRoute(): status = 'OK' message = 'List of several questions by user_id' elif 'engineer' in questionArgs: - questions = Questions.getQuestionsByEngineer(questionArgs['engineer'], id) + questions = Questions.getQuestionByEngineer(questionArgs['engineer'], id) success = True status = 'OK' message = 'List of several questions by engineer' diff --git a/application/models/Questions.py b/application/models/Questions.py index 60f8217..f2df424 100644 --- a/application/models/Questions.py +++ b/application/models/Questions.py @@ -93,7 +93,7 @@ def deleteQuestion(id): return response -### NOT USED +# NOT SURE IF WORKS, SHOULD BE TESTED def modifyQuestion(id, title, text, engineer): response = False question = getQuestion(id) @@ -180,7 +180,7 @@ def getQuestionsByUser(user_id, loggedin_id): # Get all Question returns list of users or an empty list -def getQuestionsByEngineer(engineer, loggedin_id): +def getQuestionByEngineer(engineer, loggedin_id): from application.models import Users from application.models import Votes response = [] diff --git a/test.py b/test.py index 39852e3..090bbb4 100644 --- a/test.py +++ b/test.py @@ -5,37 +5,12 @@ def test_questions(): - - - # create test user - Users.createUser("Mark", "Hamill", "starwarsfan", "wookie", "Space", "chewbaca", True) - id = getUserId("starwarsfan") - - if questions.questionExists(1): + Questions.createQuestion("Question", "Please Answer", "software", 1) + questions = Questions.getQuestionsByUser(1, 0) + if questions: + return 0 + else: return 1 - - - - Questions.createQuestion("Question", "Please Answer", "software", id) - questions = Questions.getQuestionsByUser(id, 0) - if not questions: - return 2 - - question = Questions.getQuestion(1) - if not question: - return 3 - - Questions.updateTags(1, "tag1 tag2 tag3") - - if question.tags != "tag1 tag2 tag3": - return 4 - - if Questions.getQuestionsByEngineer('software', id): - return 5 - - if not Questions.deleteQuestion(1): - return 6 - return 0 @@ -55,7 +30,7 @@ def test_users(): return 1 if Users.userVerified("starwarsfan", "wookie"): return 2 - if Users.modifyUser(1, "Boba", "Fett", "Killer"): + if Users.modifyUser(1, "Boba", "Fett", "Killer", "starwarsfan"): return 3 # test with existing user @@ -75,7 +50,7 @@ def test_users(): return 8 if user["password_hash"] == "wookie": return 9 - if not Users.modifyUser(user["id"], "Han", "Solo", "Ship"): + if not Users.modifyUser(user["id"], "Han", "Solo", "Ship", "starwarsfan"): return 10 user = Users.getUser("starwarsfan") if user["fname"] != "Han" or user["lname"] != "Solo" or user["engineer"] != "Ship":