def test_one_collection_with_missing_snapshot_is_pseudonymized(self):
    collection_models.CollectionCommitLogEntryModel(id=('collection-%s-1' % self.COL_2_ID), collection_id=self.COL_2_ID, user_id=self.user_1_id, commit_type='create_new', commit_cmds=[{}], post_commit_status=constants.ACTIVITY_STATUS_PUBLIC, version=1).put_for_human()
    with self.capture_logging(min_level=logging.ERROR) as log_messages:
        wipeout_service.pre_delete_user(self.user_1_id)
        self.process_and_flush_pending_tasks()
        wipeout_service.delete_user(wipeout_service.get_pending_deletion_request(self.user_1_id))
    self.assertItemsEqual(log_messages, [("[WIPEOUT] The commit log model 'CollectionCommitLogEntryModel' and snapshot models ['CollectionSnapshotMetadataModel', 'CollectionRightsSnapshotMetadataModel'] IDs differ. Snapshots without commit logs: [], commit logs without snapshots: [u'%s']." % self.COL_2_ID), "[WIPEOUT] The commit log model 'ExplorationCommitLogEntryModel' and snapshot models ['ExplorationSnapshotMetadataModel', 'ExplorationRightsSnapshotMetadataModel'] IDs differ. Snapshots without commit logs: [], commit logs without snapshots: [u'an_exploration_id']."])
    collection_mappings = user_models.PendingDeletionRequestModel.get_by_id(self.user_1_id).pseudonymizable_entity_mappings[models.NAMES.collection]
    metadata_model = collection_models.CollectionSnapshotMetadataModel.get_by_id(('%s-1' % self.COL_1_ID))
    self.assertEqual(metadata_model.committer_id, collection_mappings[self.COL_1_ID])
    commit_log_model_1 = collection_models.CollectionCommitLogEntryModel.get_by_id(('collection-%s-1' % self.COL_1_ID))
    self.assertEqual(commit_log_model_1.user_id, collection_mappings[self.COL_1_ID])
    commit_log_model_2 = collection_models.CollectionCommitLogEntryModel.get_by_id(('collection-%s-1' % self.COL_2_ID))
    self.assertEqual(commit_log_model_2.user_id, collection_mappings[self.COL_2_ID])
def test_one_collection_with_missing_snapshot_is_pseudonymized(self):
    collection_models.CollectionCommitLogEntryModel(id=('collection-%s-1' % self.COL_2_ID), collection_id=self.COL_2_ID, user_id=self.user_1_id, commit_type='create_new', commit_cmds=[{}], post_commit_status=constants.ACTIVITY_STATUS_PUBLIC, version=1).put_for_human()
    with self.capture_logging(min_level=logging.ERROR) as log_messages:
        wipeout_service.pre_delete_user(self.user_1_id)
        self.process_and_flush_pending_tasks()
        wipeout_service.delete_user(wipeout_service.get_pending_deletion_request(self.user_1_id))
    self.assertItemsEqual(log_messages, [("[WIPEOUT] The commit log model 'CollectionCommitLogEntryModel' and snapshot models ['CollectionSnapshotMetadataModel', 'CollectionRightsSnapshotMetadataModel'] IDs differ. Snapshots without commit logs: [], commit logs without snapshots: [u'%s']." % self.COL_2_ID), "[WIPEOUT] The commit log model 'ExplorationCommitLogEntryModel' and snapshot models ['ExplorationSnapshotMetadataModel', 'ExplorationRightsSnapshotMetadataModel'] IDs differ. Snapshots without commit logs: [], commit logs without snapshots: [u'an_exploration_id']."])
    collection_mappings = user_models.PendingDeletionRequestModel.get_by_id(self.user_1_id).pseudonymizable_entity_mappings[models.NAMES.collection]
    metadata_model = collection_models.CollectionSnapshotMetadataModel.get_by_id(('%s-1' % self.COL_1_ID))
    self.assertEqual(metadata_model.committer_id, collection_mappings[self.COL_1_ID])
    commit_log_model_1 = collection_models.CollectionCommitLogEntryModel.get_by_id(('collection-%s-1' % self.COL_1_ID))
    self.assertEqual(commit_log_model_1.user_id, collection_mappings[self.COL_1_ID])
    commit_log_model_2 = collection_models.CollectionCommitLogEntryModel.get_by_id(('collection-%s-1' % self.COL_2_ID))
    self.assertEqual(commit_log_model_2.user_id, collection_mappings[self.COL_2_ID])