diff --git a/application/api/qa.py b/application/api/qa.py index 475a651..cd244dc 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.getQuestionByEngineer(questionArgs['engineer'], id) + questions = Questions.getQuestionsByEngineer(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 f2df424..60f8217 100644 --- a/application/models/Questions.py +++ b/application/models/Questions.py @@ -93,7 +93,7 @@ def deleteQuestion(id): return response -# NOT SURE IF WORKS, SHOULD BE TESTED +### NOT USED 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 getQuestionByEngineer(engineer, loggedin_id): +def getQuestionsByEngineer(engineer, loggedin_id): from application.models import Users from application.models import Votes response = [] diff --git a/test.py b/test.py index 090bbb4..39852e3 100644 --- a/test.py +++ b/test.py @@ -5,12 +5,37 @@ def test_questions(): - Questions.createQuestion("Question", "Please Answer", "software", 1) - questions = Questions.getQuestionsByUser(1, 0) - if questions: - return 0 - else: + + + # create test user + Users.createUser("Mark", "Hamill", "starwarsfan", "wookie", "Space", "chewbaca", True) + id = getUserId("starwarsfan") + + if questions.questionExists(1): 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 @@ -30,7 +55,7 @@ def test_users(): return 1 if Users.userVerified("starwarsfan", "wookie"): return 2 - if Users.modifyUser(1, "Boba", "Fett", "Killer", "starwarsfan"): + if Users.modifyUser(1, "Boba", "Fett", "Killer"): return 3 # test with existing user @@ -50,7 +75,7 @@ def test_users(): return 8 if user["password_hash"] == "wookie": return 9 - if not Users.modifyUser(user["id"], "Han", "Solo", "Ship", "starwarsfan"): + if not Users.modifyUser(user["id"], "Han", "Solo", "Ship"): return 10 user = Users.getUser("starwarsfan") if user["fname"] != "Han" or user["lname"] != "Solo" or user["engineer"] != "Ship":