'Test that discussion xblock render successfully
if discussion xblock is child of an orphan.'

@ddt.data(ModuleStoreEnum.Type.mongo, ModuleStoreEnum.Type.split)
def test_discussion_render_successfully_with_orphan_parent(self, default_store):

    with self.store.default_store(default_store):
        orphan_sequential = self.store.create_item(self.user.id, self.course.id, 'sequential')
        vertical = self.store.create_child(self.user.id, orphan_sequential.location, 'vertical', block_id=self.course.location.block_id)
        discussion = self.store.create_child(self.user.id, vertical.location, 'discussion', block_id=self.course.location.block_id)
        discussion = self.store.get_item(discussion.location)
        root = self.get_root(discussion)
        self.assertEqual(orphan_sequential.location.block_type, root.location.block_type)
        self.assertEqual(orphan_sequential.location.block_id, root.location.block_id)
        discussion_xblock = get_module_for_descriptor_internal(user=self.user, descriptor=discussion, student_data=mock.Mock(name='student_data'), course_id=self.course.id, track_function=mock.Mock(name='track_function'), xqueue_callback_url_prefix=mock.Mock(name='xqueue_callback_url_prefix'), request_token='request_token')
        fragment = discussion_xblock.render('student_view')
        html = fragment.content
        self.assertIsInstance(discussion_xblock, DiscussionXBlock)
        self.assertIn('data-user-create-comment="false"', html)
        self.assertIn('data-user-create-subcomment="false"', html)
