'Test the "assigned" event emitted when a student is assigned specific blocks.'

def test_assigned_event(self):

    child = self.lc_block.get_child_descriptors()[0]
    (child_lib_location, child_lib_version) = self.store.get_block_original_usage(child.location)
    self.assertIsInstance(child_lib_version, ObjectId)
    event_data = self._assert_event_was_published('assigned')
    block_info = {'usage_key': unicode(child.location), 'original_usage_key': unicode(child_lib_location), 'original_usage_version': unicode(child_lib_version), 'descendants': []}
    self.assertEqual(event_data, {'location': unicode(self.lc_block.location), 'added': [block_info], 'result': [block_info], 'previous_count': 0, 'max_count': 1})
    self.publisher.reset_mock()
    self.lc_block.max_count = 2
    del self.lc_block._xmodule._selected_set
    children = self.lc_block.get_child_descriptors()
    self.assertEqual(len(children), 2)
    (child, new_child) = (children if (children[0].location == child.location) else reversed(children))
    event_data = self._assert_event_was_published('assigned')
    self.assertEqual(event_data['added'][0]['usage_key'], unicode(new_child.location))
    self.assertEqual(len(event_data['result']), 2)
    self.assertEqual(event_data['previous_count'], 1)
    self.assertEqual(event_data['max_count'], 2)
