Exemplo n.º 1
0
def _get_message_from_model(message_model):
    """Converts the FeedbackMessageModel to a FeedbackMessage.

    Args:
        message_model: FeedbackMessageModel. The FeedbackMessageModel to
            be converted.

    Returns:
        FeedbackMessage. The resulting FeedbackMessage domain object.
    """
    return feedback_domain.FeedbackMessage(
        message_model.id, message_model.thread_id, message_model.message_id,
        message_model.author_id, message_model.updated_status,
        message_model.updated_subject, message_model.text,
        message_model.created_on, message_model.last_updated)
Exemplo n.º 2
0
 def test_to_dict(self):
     fake_date = datetime.datetime(2016, 4, 10, 0, 0, 0, 0)
     expected_message_dict = {
         'author_username': self.OWNER_USERNAME,
         'created_on': utils.get_time_in_millisecs(fake_date),
         'exploration_id': self.EXP_ID,
         'message_id': self.MESSAGE_ID,
         'text': 'a message text',
         'updated_status': 'open',
         'updated_subject': 'an updated subject'
     }
     observed_message = feedback_domain.FeedbackMessage(
         self.FULL_MESSAGE_ID, self.FULL_THREAD_ID, self.MESSAGE_ID,
         self.owner_id, expected_message_dict['updated_status'],
         expected_message_dict['updated_subject'],
         expected_message_dict['text'], fake_date, fake_date)
     self.assertDictEqual(expected_message_dict, observed_message.to_dict())
Exemplo n.º 3
0
 def test_to_dict(self) -> None:
     fake_date = datetime.datetime(2016, 4, 10, 0, 0, 0, 0)
     expected_message_dict: feedback_domain.FeedbackMessageDict = {
         'author_id': self.owner_id,
         'created_on_msecs': utils.get_time_in_millisecs(fake_date),
         'entity_type': feconf.ENTITY_TYPE_EXPLORATION,
         'entity_id': self.EXP_ID,
         'message_id': self.MESSAGE_ID,
         'text': 'a message text',
         'updated_status': 'open',
         'updated_subject': 'an updated subject'
     }
     observed_message = feedback_domain.FeedbackMessage(
         self.FULL_MESSAGE_ID, self.THREAD_ID, self.MESSAGE_ID,
         self.owner_id, expected_message_dict['updated_status'],
         expected_message_dict['updated_subject'],
         expected_message_dict['text'], fake_date, fake_date, False)
     self.assertDictEqual(expected_message_dict, observed_message.to_dict())
Exemplo n.º 4
0
 def test_to_dict(self) -> None:
     fake_date = datetime.datetime(2016, 4, 10, 0, 0, 0, 0)
     expected_message_dict: feedback_domain.FeedbackMessageDict = {
         'author_username': self.OWNER_USERNAME,
         'created_on_msecs': utils.get_time_in_millisecs(fake_date),
         'entity_type': feconf.ENTITY_TYPE_EXPLORATION,
         'entity_id': self.EXP_ID,
         'message_id': self.MESSAGE_ID,
         'text': 'a message text',
         'updated_status': 'open',
         'updated_subject': 'an updated subject'
     }
     observed_message = feedback_domain.FeedbackMessage(
         self.FULL_MESSAGE_ID, self.THREAD_ID, self.MESSAGE_ID,
         self.owner_id, expected_message_dict['updated_status'],
         expected_message_dict['updated_subject'],
         expected_message_dict['text'], fake_date, fake_date, False)
     # Using type ignore[arg-type] here because assertDictEqual method
     # expects both arguments to be of type Dict[Any, Any].
     self.assertDictEqual(
         expected_message_dict, observed_message.to_dict()) # type: ignore[arg-type]
Exemplo n.º 5
0
def _get_message_from_model(message_model):
    return feedback_domain.FeedbackMessage(
        message_model.id, message_model.thread_id, message_model.message_id,
        message_model.author_id, message_model.updated_status,
        message_model.updated_subject, message_model.text,
        message_model.created_on, message_model.last_updated)