'Test that the same student will always see the same selected child block'

def test_consistent_children(self):

    for num in range(8):
        ItemFactory.create(data='This    is    #{}'.format((num + 1)), category='html', parent_location=self.library.location, user_id=self.user.id, publish_item=False)
    with modulestore().default_store(ModuleStoreEnum.Type.split):
        course = CourseFactory.create()
    lc_block = self._add_library_content_block(course, self.lib_key, {'max_count': 1})
    lc_block_key = lc_block.location
    lc_block = self._refresh_children(lc_block)
    def get_child_of_lc_block(block):
        '\n                                                Fetch    the    child    shown    to    the    current    user.\n                                                '
        children = block.get_child_descriptors()
        self.assertEqual(len(children), 1)
        return children[0]
    self._bind_module(lc_block)
    chosen_child = get_child_of_lc_block(lc_block)
    chosen_child_defn_id = chosen_child.definition_locator.definition_id
    lc_block.save()
    modulestore().update_item(lc_block, self.user.id)
    def check():
        '\n                                                Confirm    that    chosen_child    is    still    the    child    seen    by    the    test    student\n                                                '
        for _ in range(6):
            lc_block = modulestore().get_item(lc_block_key)
            self._bind_module(lc_block)
            current_child = get_child_of_lc_block(lc_block)
            self.assertEqual(current_child.location, chosen_child.location)
            self.assertEqual(current_child.data, chosen_child.data)
            self.assertEqual(current_child.definition_locator.definition_id, chosen_child_defn_id)
    check()
    lc_block = self._refresh_children(lc_block)
    check()
