def test_one_question_with_multiple_users_is_pseudonymized(self):
    question_services.update_question(self.user_2_id, self.QUESTION_1_ID, [question_domain.QuestionChange({'cmd': question_domain.CMD_UPDATE_QUESTION_PROPERTY, 'property_name': question_domain.QUESTION_PROPERTY_LANGUAGE_CODE, 'new_value': 'cs', 'old_value': 'en'})], 'Change language.')
    wipeout_service.delete_user(wipeout_service.get_pending_deletion_request(self.user_1_id))
    question_mappings_1 = user_models.PendingDeletionRequestModel.get_by_id(self.user_1_id).pseudonymizable_entity_mappings[models.NAMES.question]
    metadata_model = question_models.QuestionSnapshotMetadataModel.get_by_id(('%s-1' % self.QUESTION_1_ID))
    self.assertEqual(metadata_model.committer_id, question_mappings_1[self.QUESTION_1_ID])
    commit_log_model = question_models.QuestionCommitLogEntryModel.get_by_id(('question-%s-1' % self.QUESTION_1_ID))
    self.assertEqual(commit_log_model.user_id, question_mappings_1[self.QUESTION_1_ID])
    metadata_model = question_models.QuestionSnapshotMetadataModel.get_by_id(('%s-2' % self.QUESTION_1_ID))
    self.assertEqual(metadata_model.committer_id, self.user_2_id)
    commit_log_model = question_models.QuestionCommitLogEntryModel.get_by_id(('question-%s-2' % self.QUESTION_1_ID))
    self.assertEqual(commit_log_model.user_id, self.user_2_id)
    wipeout_service.delete_user(wipeout_service.get_pending_deletion_request(self.user_2_id))
    question_mappings_2 = user_models.PendingDeletionRequestModel.get_by_id(self.user_2_id).pseudonymizable_entity_mappings[models.NAMES.question]
    metadata_model = question_models.QuestionSnapshotMetadataModel.get_by_id(('%s-2' % self.QUESTION_1_ID))
    self.assertEqual(metadata_model.committer_id, question_mappings_2[self.QUESTION_1_ID])
    commit_log_model = question_models.QuestionCommitLogEntryModel.get_by_id(('question-%s-2' % self.QUESTION_1_ID))
    self.assertEqual(commit_log_model.user_id, question_mappings_2[self.QUESTION_1_ID])
def test_one_question_with_multiple_users_is_pseudonymized(self):
    question_services.update_question(self.user_2_id, self.QUESTION_1_ID, [question_domain.QuestionChange({'cmd': question_domain.CMD_UPDATE_QUESTION_PROPERTY, 'property_name': question_domain.QUESTION_PROPERTY_LANGUAGE_CODE, 'new_value': 'cs', 'old_value': 'en'})], 'Change language.')
    wipeout_service.delete_user(wipeout_service.get_pending_deletion_request(self.user_1_id))
    question_mappings_1 = user_models.PendingDeletionRequestModel.get_by_id(self.user_1_id).pseudonymizable_entity_mappings[models.NAMES.question]
    metadata_model = question_models.QuestionSnapshotMetadataModel.get_by_id(('%s-1' % self.QUESTION_1_ID))
    self.assertEqual(metadata_model.committer_id, question_mappings_1[self.QUESTION_1_ID])
    commit_log_model = question_models.QuestionCommitLogEntryModel.get_by_id(('question-%s-1' % self.QUESTION_1_ID))
    self.assertEqual(commit_log_model.user_id, question_mappings_1[self.QUESTION_1_ID])
    metadata_model = question_models.QuestionSnapshotMetadataModel.get_by_id(('%s-2' % self.QUESTION_1_ID))
    self.assertEqual(metadata_model.committer_id, self.user_2_id)
    commit_log_model = question_models.QuestionCommitLogEntryModel.get_by_id(('question-%s-2' % self.QUESTION_1_ID))
    self.assertEqual(commit_log_model.user_id, self.user_2_id)
    wipeout_service.delete_user(wipeout_service.get_pending_deletion_request(self.user_2_id))
    question_mappings_2 = user_models.PendingDeletionRequestModel.get_by_id(self.user_2_id).pseudonymizable_entity_mappings[models.NAMES.question]
    metadata_model = question_models.QuestionSnapshotMetadataModel.get_by_id(('%s-2' % self.QUESTION_1_ID))
    self.assertEqual(metadata_model.committer_id, question_mappings_2[self.QUESTION_1_ID])
    commit_log_model = question_models.QuestionCommitLogEntryModel.get_by_id(('question-%s-2' % self.QUESTION_1_ID))
    self.assertEqual(commit_log_model.user_id, question_mappings_2[self.QUESTION_1_ID])