def test_add_commit_cmds_user_ids_to_topic_rights_snapshot(self):
    with self.topic_rights_model_swap:
        topic_model = topic_models.TopicRightsModel(id=self.TOP_1_ID, manager_ids=[self.USER_1_ID])
        topic_model.commit('cid', 'Created new topic rights', [{'cmd': rights_domain.CMD_CREATE_NEW}])
        topic_model.manager_ids = [self.USER_1_ID, self.USER_3_ID]
        topic_model.commit('cid', 'Add manager', [{'cmd': topic_domain.CMD_CHANGE_ROLE, 'assignee_id': self.USER_3_ID, 'old_role': topic_domain.ROLE_NONE, 'new_role': topic_domain.ROLE_MANAGER}])
        topic_model.manager_ids = [self.USER_3_ID]
        topic_model.commit('cid', 'Remove manager', [{'cmd': topic_domain.CMD_REMOVE_MANAGER_ROLE, 'removed_user_id': self.USER_1_ID}])
    output = self._run_one_off_job()
    self.assertEqual(output, [['SUCCESS-TopicRightsSnapshotMetadataModel', 3]])
    self.assertItemsEqual([], topic_models.TopicRightsSnapshotMetadataModel.get_by_id(('%s-1' % self.TOP_1_ID)).commit_cmds_user_ids)
    self.assertItemsEqual([self.USER_3_ID], topic_models.TopicRightsSnapshotMetadataModel.get_by_id(('%s-2' % self.TOP_1_ID)).commit_cmds_user_ids)
    self.assertItemsEqual([self.USER_1_ID], topic_models.TopicRightsSnapshotMetadataModel.get_by_id(('%s-3' % self.TOP_1_ID)).commit_cmds_user_ids)
def test_add_commit_cmds_user_ids_to_topic_rights_snapshot(self):
    with self.topic_rights_model_swap:
        topic_model = topic_models.TopicRightsModel(id=self.TOP_1_ID, manager_ids=[self.USER_1_ID])
        topic_model.commit('cid', 'Created new topic rights', [{'cmd': rights_domain.CMD_CREATE_NEW}])
        topic_model.manager_ids = [self.USER_1_ID, self.USER_3_ID]
        topic_model.commit('cid', 'Add manager', [{'cmd': topic_domain.CMD_CHANGE_ROLE, 'assignee_id': self.USER_3_ID, 'old_role': topic_domain.ROLE_NONE, 'new_role': topic_domain.ROLE_MANAGER}])
        topic_model.manager_ids = [self.USER_3_ID]
        topic_model.commit('cid', 'Remove manager', [{'cmd': topic_domain.CMD_REMOVE_MANAGER_ROLE, 'removed_user_id': self.USER_1_ID}])
    output = self._run_one_off_job()
    self.assertEqual(output, [['SUCCESS-TopicRightsSnapshotMetadataModel', 3]])
    self.assertItemsEqual([], topic_models.TopicRightsSnapshotMetadataModel.get_by_id(('%s-1' % self.TOP_1_ID)).commit_cmds_user_ids)
    self.assertItemsEqual([self.USER_3_ID], topic_models.TopicRightsSnapshotMetadataModel.get_by_id(('%s-2' % self.TOP_1_ID)).commit_cmds_user_ids)
    self.assertItemsEqual([self.USER_1_ID], topic_models.TopicRightsSnapshotMetadataModel.get_by_id(('%s-3' % self.TOP_1_ID)).commit_cmds_user_ids)