# Path: soco/data_structures.py
# _FROM_DIDL_STRING_FUNCTION = None
# _OFFICIAL_CLASSES = {
#     "object",
#     "object.item",
#     "object.item.audioItem",
#     "object.item.audioItem.musicTrack",
#     "object.item.audioItem.audioBroadcast",
#     "object.item.audioItem.audioBook",
#     "object.container",
#     "object.container.person",
#     "object.container.person.musicArtist",
#     "object.container.playlistContainer",
#     "object.container.album",
#     "object.container.musicAlbum",
#     "object.container.genre",
#     "object.container.musicGenre",
# }
# _DIDL_CLASS_TO_CLASS = {}
#             _FROM_DIDL_STRING_FUNCTION = data_structures_entry.from_didl_string
# def to_didl_string(*args):
# def didl_class_to_soco_class(didl_class):
# def form_name(didl_class):
#     def __init__(
#         self,
#         uri,
#         protocol_info,
#         import_uri=None,
#         size=None,
#         duration=None,
#         bitrate=None,
#         sample_frequency=None,
#         bits_per_sample=None,
#         nr_audio_channels=None,
#         resolution=None,
#         color_depth=None,
#         protection=None,
#     ):
#     def from_element(cls, element):
#         def _int_helper(name):
#     def __repr__(self):
#     def __str__(self):
#     def to_element(self):
#     def to_dict(self, remove_nones=False):
#     def from_dict(cls, content):
#     def __eq__(self, resource):
#     def __new__(cls, name, bases, attrs):
#     def __init__(
#         self,
#         title,
#         parent_id,
#         item_id,
#         restricted=True,
#         resources=None,
#         desc="RINCON_AssociatedZPUDN",
#         **kwargs
#     ):
#     def from_element(cls, element):  # pylint: disable=R0914
#     def from_dict(cls, content):
#     def __eq__(self, playable_item):
#     def __ne__(self, playable_item):
#     def __repr__(self):
#     def __str__(self):
#     def to_dict(self, remove_nones=False):
#     def to_element(self, include_namespaces=False):
#     def get_uri(self, resource_nr=0):
#     def set_uri(self, uri, resource_nr=0, protocol_info=None):
#     def reference(self):
#     def reference(self, value):
#     def __init__(self, items, number_returned, total_matches, update_id):
#     def __getitem__(self, key):
#     def number_returned(self):
#     def total_matches(self):
#     def update_id(self):
#     def __init__(self, items, search_type, number_returned, total_matches, update_id):
#     def __repr__(self):
#     def search_type(self):
#     def __repr__(self):
# class DidlResource:
# class DidlMetaClass(type):
# class DidlObject(metaclass=DidlMetaClass):
# class DidlItem(DidlObject):
# class DidlAudioItem(DidlItem):
# class DidlMusicTrack(DidlAudioItem):
# class DidlAudioBook(DidlAudioItem):
# class DidlAudioBroadcast(DidlAudioItem):
# class DidlRecentShow(DidlMusicTrack):
# class DidlAudioBroadcastFavorite(DidlAudioBroadcast):
# class DidlFavorite(DidlItem):
# class DidlContainer(DidlObject):
# class DidlAlbum(DidlContainer):
# class DidlMusicAlbum(DidlAlbum):
# class DidlMusicAlbumFavorite(DidlMusicAlbum):
# class DidlMusicAlbumCompilation(DidlMusicAlbum):
# class DidlPerson(DidlContainer):
# class DidlComposer(DidlPerson):
# class DidlMusicArtist(DidlPerson):
# class DidlAlbumList(DidlContainer):
# class DidlPlaylistContainer(DidlContainer):
# class DidlSameArtist(DidlPlaylistContainer):
# class DidlPlaylistContainerFavorite(DidlPlaylistContainer):
# class DidlPlaylistContainerTracklist(DidlPlaylistContainer):
# class DidlGenre(DidlContainer):
# class DidlMusicGenre(DidlGenre):
# class DidlRadioShow(DidlContainer):
# class ListOfMusicInfoItems(list):
# class SearchResult(ListOfMusicInfoItems):
# class Queue(ListOfMusicInfoItems):
# 
# Path: soco/exceptions.py
# class DIDLMetadataError(CannotCreateDIDLMetadata):
# 
#     """Raised if a data container class cannot create the DIDL metadata due to
#     missing information.
# 
#     For backward compatibility, this is currently a subclass of
#     `CannotCreateDIDLMetadata`. In a future version, it will likely become
#     a direct subclass of `SoCoException`.
#     """


import pytest
from soco import data_structures
from soco.exceptions import DIDLMetadataError
from soco.xml import XML
        assert didl_object.desc == "DUMMY"
        assert didl_object.item_class == "object"

    def test_didl_object_from_element_unoff_subelement(self):
        """Test that for a DidlObject created from an element with an
        unofficial .# specified sub class, that the sub class is
        completely ignored

        """
        elt = XML.fromstring(self.didl_xml.replace("object", "object.#SubClass"))
        didl_object = data_structures.DidlObject.from_element(elt)
        assert didl_object.item_class == "object"

    def test_didl_object_from_wrong_class(self):
        # mismatched upnp class
        bad_elt1 = XML.fromstring(
            """<item xmlns="urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/"
              xmlns:dc="http://purl.org/dc/elements/1.1/"
              xmlns:upnp="urn:schemas-upnp-org:metadata-1-0/upnp/"
              id="iid" parentID="pid" restricted="true">
                 <dc:title>the_title</dc:title>
                 <upnp:class>object.item</upnp:class>
                 <dc:creator>a_creator</dc:creator>
                 <desc id="cdudn"
                   nameSpace="urn:schemas-rinconnetworks-com:metadata-1-0/">
                   RINCON_AssociatedZPUDN
                 </desc>
               </item>
        """
        )

# Path: soco/data_structures.py
# _FROM_DIDL_STRING_FUNCTION = None
# _OFFICIAL_CLASSES = {
#     "object",
#     "object.item",
#     "object.item.audioItem",
#     "object.item.audioItem.musicTrack",
#     "object.item.audioItem.audioBroadcast",
#     "object.item.audioItem.audioBook",
#     "object.container",
#     "object.container.person",
#     "object.container.person.musicArtist",
#     "object.container.playlistContainer",
#     "object.container.album",
#     "object.container.musicAlbum",
#     "object.container.genre",
#     "object.container.musicGenre",
# }
# _DIDL_CLASS_TO_CLASS = {}
#             _FROM_DIDL_STRING_FUNCTION = data_structures_entry.from_didl_string
# def to_didl_string(*args):
# def didl_class_to_soco_class(didl_class):
# def form_name(didl_class):
#     def __init__(
#         self,
#         uri,
#         protocol_info,
#         import_uri=None,
#         size=None,
#         duration=None,
#         bitrate=None,
#         sample_frequency=None,
#         bits_per_sample=None,
#         nr_audio_channels=None,
#         resolution=None,
#         color_depth=None,
#         protection=None,
#     ):
#     def from_element(cls, element):
#         def _int_helper(name):
#     def __repr__(self):
#     def __str__(self):
#     def to_element(self):
#     def to_dict(self, remove_nones=False):
#     def from_dict(cls, content):
#     def __eq__(self, resource):
#     def __new__(cls, name, bases, attrs):
#     def __init__(
#         self,
#         title,
#         parent_id,
#         item_id,
#         restricted=True,
#         resources=None,
#         desc="RINCON_AssociatedZPUDN",
#         **kwargs
#     ):
#     def from_element(cls, element):  # pylint: disable=R0914
#     def from_dict(cls, content):
#     def __eq__(self, playable_item):
#     def __ne__(self, playable_item):
#     def __repr__(self):
#     def __str__(self):
#     def to_dict(self, remove_nones=False):
#     def to_element(self, include_namespaces=False):
#     def get_uri(self, resource_nr=0):
#     def set_uri(self, uri, resource_nr=0, protocol_info=None):
#     def reference(self):
#     def reference(self, value):
#     def __init__(self, items, number_returned, total_matches, update_id):
#     def __getitem__(self, key):
#     def number_returned(self):
#     def total_matches(self):
#     def update_id(self):
#     def __init__(self, items, search_type, number_returned, total_matches, update_id):
#     def __repr__(self):
#     def search_type(self):
#     def __repr__(self):
# class DidlResource:
# class DidlMetaClass(type):
# class DidlObject(metaclass=DidlMetaClass):
# class DidlItem(DidlObject):
# class DidlAudioItem(DidlItem):
# class DidlMusicTrack(DidlAudioItem):
# class DidlAudioBook(DidlAudioItem):
# class DidlAudioBroadcast(DidlAudioItem):
# class DidlRecentShow(DidlMusicTrack):
# class DidlAudioBroadcastFavorite(DidlAudioBroadcast):
# class DidlFavorite(DidlItem):
# class DidlContainer(DidlObject):
# class DidlAlbum(DidlContainer):
# class DidlMusicAlbum(DidlAlbum):
# class DidlMusicAlbumFavorite(DidlMusicAlbum):
# class DidlMusicAlbumCompilation(DidlMusicAlbum):
# class DidlPerson(DidlContainer):
# class DidlComposer(DidlPerson):
# class DidlMusicArtist(DidlPerson):
# class DidlAlbumList(DidlContainer):
# class DidlPlaylistContainer(DidlContainer):
# class DidlSameArtist(DidlPlaylistContainer):
# class DidlPlaylistContainerFavorite(DidlPlaylistContainer):
# class DidlPlaylistContainerTracklist(DidlPlaylistContainer):
# class DidlGenre(DidlContainer):
# class DidlMusicGenre(DidlGenre):
# class DidlRadioShow(DidlContainer):
# class ListOfMusicInfoItems(list):
# class SearchResult(ListOfMusicInfoItems):
# class Queue(ListOfMusicInfoItems):
# 
# Path: soco/exceptions.py
# class DIDLMetadataError(CannotCreateDIDLMetadata):
# 
#     """Raised if a data container class cannot create the DIDL metadata due to
#     missing information.
# 
#     For backward compatibility, this is currently a subclass of
#     `CannotCreateDIDLMetadata`. In a future version, it will likely become
#     a direct subclass of `SoCoException`.
#     """


# Path: tests/test_new_datastructures.py
import pytest
from soco import data_structures
from soco.exceptions import DIDLMetadataError
from soco.xml import XML

        assert didl_object.desc == "DUMMY"
        assert didl_object.item_class == "object"

    def test_didl_object_from_element_unoff_subelement(self):
        """Test that for a DidlObject created from an element with an
        unofficial .# specified sub class, that the sub class is
        completely ignored

        """
        elt = XML.fromstring(self.didl_xml.replace("object", "object.#SubClass"))
        didl_object = data_structures.DidlObject.from_element(elt)
        assert didl_object.item_class == "object"

    def test_didl_object_from_wrong_class(self):
        # mismatched upnp class
        bad_elt1 = XML.fromstring(
            """<item xmlns="urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/"
              xmlns:dc="http://purl.org/dc/elements/1.1/"
              xmlns:upnp="urn:schemas-upnp-org:metadata-1-0/upnp/"
              id="iid" parentID="pid" restricted="true">
                 <dc:title>the_title</dc:title>
                 <upnp:class>object.item</upnp:class>
                 <dc:creator>a_creator</dc:creator>
                 <desc id="cdudn"
                   nameSpace="urn:schemas-rinconnetworks-com:metadata-1-0/">
                   RINCON_AssociatedZPUDN
                 </desc>
               </item>
        """
        )

        with pytest.raises(DIDLMetadataError) as excinfo: