'Test the "assigned" event emitted includes descendant block information.'

def test_assigned_descendants(self):

    with self.store.bulk_operations(self.library.location.library_key):
        self.library.children = []
        main_vertical = self.make_block('vertical', self.library)
        inner_vertical = self.make_block('vertical', main_vertical)
        html_block = self.make_block('html', inner_vertical)
        problem_block = self.make_block('problem', inner_vertical)
        self.lc_block.refresh_children()
    self.lc_block = self.store.get_item(self.lc_block.location)
    self._bind_course_module(self.lc_block)
    self.lc_block.xmodule_runtime.publish = self.publisher
    course_usage_main_vertical = self.lc_block.children[0]
    course_usage_inner_vertical = self.store.get_item(course_usage_main_vertical).children[0]
    inner_vertical_in_course = self.store.get_item(course_usage_inner_vertical)
    course_usage_html = inner_vertical_in_course.children[0]
    course_usage_problem = inner_vertical_in_course.children[1]
    self.lc_block.get_child_descriptors()
    event_data = self._assert_event_was_published('assigned')
    for block_list in (event_data['added'], event_data['result']):
        self.assertEqual(len(block_list), 1)
        self.assertEqual(block_list[0]['usage_key'], unicode(course_usage_main_vertical))
        descendants_expected = ((inner_vertical.location, course_usage_inner_vertical), (html_block.location, course_usage_html), (problem_block.location, course_usage_problem))
        descendant_data_expected = {}
        for (lib_key, course_usage_key) in descendants_expected:
            descendant_data_expected[unicode(course_usage_key)] = {'usage_key': unicode(course_usage_key), 'original_usage_key': unicode(lib_key), 'original_usage_version': unicode(self.store.get_block_original_usage(course_usage_key)[1])}
        self.assertEqual(len(block_list[0]['descendants']), len(descendant_data_expected))
        for descendant in block_list[0]['descendants']:
            self.assertEqual(descendant, descendant_data_expected.get(descendant['usage_key']))
