def test_1_create_question_new_item(self): obj_request_body = {'studyId' : self.study.id, 'itemCode' : 'A4', 'itemName' : 'ABCDEF', 'itemDescription' : 'This is a good question for testing', 'introText' : 'My Test Question Intro', 'languageIso' : 'eng', 'countryIso' : 'AU', 'requestForAnswerText' : 'Please o please answer me!', "answerOptionsTexts" : ['Category One', 'Category Two']} obj_response_body = views_ui_functions.create_or_update_question(self.user, obj_request_body)[0] if not obj_response_body['id']: raise Exception('No id returned')
def test_2_create_question_existing_item(self): obj_request_body = {'studyId' : self.study.id, 'itemCode' : 'A4', 'itemName' : 'ABCDEF', 'itemDescription' : 'Ist und bon veston testin', 'introText' : 'Das is oto intro', 'languageIso' : 'deu', 'countryIso' : 'DE', 'requestForAnswerText' : 'reponze!', "answerOptionsTexts" : ['Category One', 'Category Two']} obj_response_body = views_ui_functions.create_or_update_question(self.user, obj_request_body)[0] new_question_id = obj_response_body['id'] self.assertEqual(type(new_question_id), types.LongType) question_new = models.Question.objects.get(id=new_question_id) question_existing = models.Question.objects.get(introduction_text = 'My Test Question Intro') self.assertEqual(question_new.item.id, question_existing.item.id)
def test_3_update_question(self): obj_request_body = {'studyId' : self.study.id, 'itemCode' : 'A4', 'itemName' : 'ABCDEF', 'itemDescription' : 'This is a good question for testing', 'introText' : 'My Modified Test Question Intro', 'languageIso' : 'eng', 'countryIso' : 'AU', 'requestForAnswerText' : 'Please o please answer me!', "answerOptionsTexts" : ['Category One', 'Category Two']} question_id = models.Question.objects.get(introduction_text = 'My Test Question Intro').id obj_response_body = views_ui_functions.create_or_update_question(self.user, obj_request_body, questionId = question_id)[0] self.assertEqual(obj_response_body['introText'], 'My Modified Test Question Intro')