How to use the soco.data_structures.DidlObject function in soco

To help you get started, we’ve selected a few soco examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github SoCo / SoCo / tests / test_new_datastructures.py View on Github external
def test_didl_object_from_dict(self):
        didl_object = data_structures.DidlObject(
            title='a_title',
            parent_id='pid',
            item_id='iid',
            creator='a_creator',
            desc='dummy')
        the_dict = {
            'title': 'a_title',
            'parent_id': 'pid',
            'item_id': 'iid',
            'creator': 'a_creator',
            'restricted': True,
            'desc': 'dummy'
        }
        assert data_structures.DidlObject.from_dict(the_dict) == didl_object
        # adding in an attibute not in _translation should make no difference
        the_dict['creator'] = 'another_creator'
github tdamdouni / Pythonista / automation / SoCoSono / unittest / test_new_datastructures.py View on Github external
def test_didl_object_from_dict(self):
        didl_object = data_structures.DidlObject(title='a_title',
            parent_id='pid', item_id='iid', creator='a_creator', desc='dummy')
        the_dict = {
            'title': 'a_title',
            'parent_id': 'pid',
            'item_id': 'iid',
            'creator': 'a_creator',
            'restricted': True,
            'desc': 'dummy'
        }
        assert data_structures.DidlObject.from_dict(the_dict) == didl_object
        # adding in an attibute not in _translation should make no difference
        the_dict['creator'] = 'another_creator'
        assert data_structures.DidlObject.from_dict(the_dict) != didl_object
        # round trip
        assert data_structures.DidlObject.from_dict(the_dict).to_dict() == \
            the_dict
github SoCo / SoCo / tests / test_new_datastructures.py View on Github external
def test_didl_object_to_dict_resources_remove_nones(self):
        resources_list = [data_structures.DidlResource('a%20uri',
                                                       'a:protocol:info:xx')]
        didl_object = data_structures.DidlObject(title='a_title',
                                                 parent_id='pid',
                                                 item_id='iid',
                                                 creator='a_creator',
                                                 resources=resources_list)
        the_dict = {
            'title': 'a_title',
            'parent_id': 'pid',
            'item_id': 'iid',
            'creator': 'a_creator',
            'restricted': True,
            'desc': 'RINCON_AssociatedZPUDN',
            'resources': [resource.to_dict(remove_nones=True)
                          for resource in resources_list]
        }
        assert didl_object.to_dict(remove_nones=True) == the_dict
github tdamdouni / Pythonista / automation / SoCoSono / unittest / test_new_datastructures.py View on Github external
def test_didl_object_to_element(self):
        didl_object = data_structures.DidlObject(title='a_title',
            parent_id='pid', item_id='iid', creator='a_creator')
        # we seem to have to go through this to get ElementTree to deal
        # with namespaces properly!
        elt = XML.fromstring(XML.tostring(didl_object.to_element(True)))
        elt2 = XML.fromstring('' +
                    '' +
                    'a_title' +
                    'a_creator' +
                    'object')[0]
        assert_xml_equal(elt2, elt)
github SoCo / SoCo / tests / test_new_datastructures.py View on Github external
def test_didl_resource_eq(self):
        res = data_structures.DidlResource('a%20uri', 'a:protocol:info:xx')
        assert res != data_structures.DidlObject(
            title='a_title', parent_id='pid', item_id='iid')
        assert res is not None
        assert res == res
github tdamdouni / Pythonista / automation / SoCoSono / unittest / test_new_datastructures.py View on Github external
def test_didl_comparisons(self):
        didl_object_1 = data_structures.DidlObject(title='a_title',
            parent_id='pid', item_id='iid', creator='a_creator')
        didl_object_2 = data_structures.DidlObject(title='a_title',
            parent_id='pid', item_id='iid', creator='a_creator')
        # should be not the same, but equal!
        assert didl_object_1 is not didl_object_2
        assert didl_object_1 == didl_object_2
        didl_object_3 = data_structures.DidlObject(title='a_title',
            parent_id='pid', item_id='iid', creator='a__different_creator')
        assert didl_object_3 != didl_object_1
github SoCo / SoCo / tests / test_new_datastructures.py View on Github external
def test_didl_object_from_dict_resources(self):
        resources_list = [data_structures.DidlResource('a%20uri',
                                                       'a:protocol:info:xx')]
        didl_object = data_structures.DidlObject(title='a_title',
                                                 parent_id='pid',
                                                 item_id='iid',
                                                 creator='a_creator',
                                                 desc='dummy',
                                                 resources=resources_list)
        the_dict = {
            'title': 'a_title',
            'parent_id': 'pid',
            'item_id': 'iid',
            'creator': 'a_creator',
            'restricted': True,
            'desc': 'dummy',
            'resources': [resource.to_dict() for resource in resources_list]
        }
        assert data_structures.DidlObject.from_dict(the_dict) == didl_object
github SoCo / SoCo / tests / test_new_datastructures.py View on Github external
def test_create_didl_object_with_no_params(self):
        with pytest.raises(TypeError):
            didl_object = data_structures.DidlObject()
github SoCo / SoCo / tests / test_new_datastructures.py View on Github external
def test_didl_comparisons(self):
        didl_object_1 = data_structures.DidlObject(
            title='a_title', parent_id='pid', item_id='iid', creator='a_creator')
        didl_object_2 = data_structures.DidlObject(
            title='a_title', parent_id='pid', item_id='iid', creator='a_creator')
        # should be not the same, but equal!
        assert didl_object_1 is not didl_object_2
        assert didl_object_1 == didl_object_2
        didl_object_3 = data_structures.DidlObject(
            title='a_title',
            parent_id='pid',
            item_id='iid',
            creator='a__different_creator')
        assert didl_object_3 != didl_object_1
github SoCo / SoCo / soco / data_structures.py View on Github external
# The resMD metadata lacks a  tag, so we use the resources from
        # the favorite to make 'reference' playable.
        ref.resources = self.resources
        return ref

    @reference.setter
    def reference(self, value):
        setattr(self, 'resource_meta_data', to_didl_string(value))
        self.resources = value.resources


###############################################################################
# OBJECT.CONTAINER HIERARCHY                                                  #
###############################################################################

class DidlContainer(DidlObject):

    """Class that represents a music library container."""

    # the DIDL Lite class for this object.
    item_class = 'object.container'
    tag = 'container'
    # We do not implement createClass or searchClass. Not used by Sonos??
    # TODO: handle the 'childCount' element.


class DidlAlbum(DidlContainer):

    """A content directory album."""

    # the DIDL Lite class for this object.
    item_class = 'object.container.album'