'Check that XBlocks that are inherited from a library include the
information about their library block source in events.
We patch the modulestore to avoid having to create a library.'

def test_library_source_information(self, mock_tracker):

    original_usage_key = UsageKey.from_string(u'block-v1:A+B+C+type@problem+block@abcd1234')
    original_usage_version = ObjectId()
    mock_get_original_usage = (lambda _, key: (original_usage_key, original_usage_version))
    with patch('xmodule.modulestore.mixed.MixedModuleStore.get_block_original_usage', mock_get_original_usage):
        module_info = self.handle_callback_and_get_module_info(mock_tracker)
        self.assertIn('original_usage_key', module_info)
        self.assertEqual(module_info['original_usage_key'], unicode(original_usage_key))
        self.assertIn('original_usage_version', module_info)
        self.assertEqual(module_info['original_usage_version'], unicode(original_usage_version))
