Example #1
0
 def test_add_consumer_preferences(self):
     '''
     This test can fail due to the new promo code not having propagated in CIDB.
     To solve, one can put time.sleep(2) before get_consumer_preferences.
     '''
     member = self.immutable_member
     cw = ConsumerWrapper()
     cw._set_preference(answer=AnswerType(OptionID=2), category_id=10, question_id=112,
         mod_flag=constants.modify_flag['INSERT'])
     # the promo code for this particular question is mandatory
     cw.consumer.Preferences.PromoCode = 'special_preference_promo'
     api.update_consumer_preferences(member.neoprofile.consumer_id, cw.consumer.Preferences,
         username=member.username, password=member.neoprofile.password, category_id=10)
     #time.sleep(5)
     prefs = api.get_consumer_preferences(member.neoprofile.consumer_id, username=member.username,
         password=member.neoprofile.password, category_id=10)
     self.assertEqual(prefs.PromoCode, 'special_preference_promo')
     question = prefs.QuestionCategory[0].QuestionAnswers[0]
     self.assertEqual(question.QuestionID, 112)
     self.assertEqual(question.Answer[0].OptionID, 2)