Example #1
0
    def test_sorting_by_order(self):
        question_key = Question.create(text="Q1", order=1)
        Answer.create(question_key=question_key, text="Answer 1", value=1, order=3)
        Answer.create(question_key=question_key, text="Answer 2", value=2, order=1)
        Answer.create(question_key=question_key, text="Answer 3", value=3, order=2)

        answers = Answer.by_question(question_key)

        self.assertEquals(1, answers[0].order)
        self.assertEquals(2, answers[1].order)
        self.assertEquals(3, answers[2].order)
Example #2
0
 def to_message(cls, entity, message_class):
     message = QuestionMessage(key=entity.key.urlsafe(),
                               text=entity.text,
                               order=entity.order,
                               answers=[])
     answers = Answer.by_question(entity.key)
     for answer in answers:
         message.answers.append(
             AnswerMessage(key=answer.key.urlsafe(),
                           text=answer.text,
                           order=answer.order,
                           value=answer.value))
     return message
Example #3
0
 def to_message(cls, entity, message_class):
     message = QuestionMessage(key=entity.key.urlsafe(), text=entity.text, order=entity.order, answers=[])
     answers = Answer.by_question(entity.key)
     for answer in answers:
         message.answers.append(AnswerMessage(key=answer.key.urlsafe(), text=answer.text, order=answer.order, value=answer.value))
     return message