示例#1
0
    def test_search_track_no_result(self, moco):
        moco.contentDirectory.reset_mock()
        # Browse returns an exception if the artist can't be found
        # <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"
        #  s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
        #   <s:Body>
        #     <s:Fault>
        #       <faultcode>s:Client</faultcode>
        #       <faultstring>UPnPError</faultstring>
        #       <detail>
        #         <UPnPError xmlns="urn:schemas-upnp-org:control-1-0">
        #           <errorCode>701</errorCode>
        #         </UPnPError>
        #       </detail>
        #     </s:Fault>
        #   </s:Body>
        # </s:Envelope>
        moco.contentDirectory.Browse.side_effect = SoCoUPnPException(
            "No such object", "701", "error XML")

        result = moco.music_library.search_track("artist")

        assert len(result) == 0

        moco.contentDirectory.Browse.assert_called_once_with([
            ("ObjectID", "A:ALBUMARTIST/artist/"),
            ("BrowseFlag", "BrowseDirectChildren"),
            ("Filter", "*"),
            ("StartingIndex", 0),
            ("RequestedCount", 100000),
            ("SortCriteria", ""),
        ])
示例#2
0
文件: test_core.py 项目: intfrr/SoCo
    def test_search_track_no_result(self, moco):
        moco.contentDirectory.reset_mock()
        # Browse returns an exception if the artist can't be found
        # <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><s:Body><s:Fault><faultcode>s:Client</faultcode><faultstring>UPnPError</faultstring><detail><UPnPError xmlns="urn:schemas-upnp-org:control-1-0"><errorCode>701</errorCode></UPnPError></detail></s:Fault></s:Body></s:Envelope>
        moco.contentDirectory.Browse.side_effect = SoCoUPnPException(
            "No such object", "701", "error XML")

        result = moco.search_track("artist")

        assert len(result) == 0

        moco.contentDirectory.Browse.assert_called_once_with([
            ('ObjectID', 'A:ALBUMARTIST/artist/'),
            ('BrowseFlag', 'BrowseDirectChildren'), ('Filter', '*'),
            ('StartingIndex', 0), ('RequestedCount', 100000),
            ('SortCriteria', '')
        ])