当前位置: 首页>>代码示例>>Python>>正文


Python PlaylistTrack.delete方法代码示例

本文整理汇总了Python中playlists.models.PlaylistTrack.delete方法的典型用法代码示例。如果您正苦于以下问题:Python PlaylistTrack.delete方法的具体用法?Python PlaylistTrack.delete怎么用?Python PlaylistTrack.delete使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在playlists.models.PlaylistTrack的用法示例。


在下文中一共展示了PlaylistTrack.delete方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: TestLive365PlaylistTasks

# 需要导入模块: from playlists.models import PlaylistTrack [as 别名]
# 或者: from playlists.models.PlaylistTrack import delete [as 别名]

#.........这里部分代码省略.........
                                .returns("<service response>"))

        with fudge.patched_context(playlists.tasks.urllib2, "urlopen", fake_urlopen):
            resp = self.client.post(reverse('playlists.send_track_to_live365'), {
                'id': self.track.key()
            })

        fudge.verify()

    def test_create_latin_chars(self):

        self.playlist = ChirpBroadcast()
        selector = self.get_selector()
        self.track = PlaylistTrack(
                    playlist=self.playlist,
                    selector=selector,
                    freeform_artist_name=u'Bj\xf6rk',
                    freeform_album_title=u'Bj\xf6rk album',
                    freeform_track_title=u'Bj\xf6rk song')
        self.track.put()

        def inspect_request(r):
            # NOTE: due to URL fetching, you can only raise
            # AssertionError here
            self.assertEqual(r.get_full_url(), 'http://__dummylive365service__/cgi-bin/add_song.cgi')
            qs = dict(cgi.parse_qsl(r.data))
            self.assertEqual(qs['member_name'], "dummy_member")
            self.assertEqual(qs['password'], "dummy_password")
            self.assertEqual(qs['seconds'], '30')
            # c should be replaced because latin-1 can't encode that and Live365 likes latin-1
            self.assertEqual(qs['title'], 'Bj\xf6rk song')
            self.assertEqual(qs['album'], 'Bj\xf6rk album')
            self.assertEqual(qs['artist'], 'Bj\xf6rk')
            return True

        fake_urlopen = (fudge.Fake('urlopen', expect_call=True)
                                .with_args(arg.passes_test(inspect_request)))

        fake_response = (fake_urlopen
                                .returns_fake()
                                .has_attr(code='200')
                                .provides('read')
                                .returns("<service response>"))

        with fudge.patched_context(playlists.tasks.urllib2, "urlopen", fake_urlopen):
            resp = self.client.post(reverse('playlists.send_track_to_live365'), {
                'id': self.track.key()
            })

        fudge.verify()

    def test_create_ascii_chars(self):

        self.playlist = ChirpBroadcast()
        selector = self.get_selector()
        self.track = PlaylistTrack(
                    playlist=self.playlist,
                    selector=selector,
                    freeform_artist_name=u'artist',
                    freeform_album_title=u'album',
                    freeform_track_title=u'song')
        self.track.put()

        def inspect_request(r):
            # NOTE: due to URL fetching, you can only raise
            # AssertionError here
            self.assertEqual(r.get_full_url(), 'http://__dummylive365service__/cgi-bin/add_song.cgi')
            qs = dict(cgi.parse_qsl(r.data))
            self.assertEqual(qs['member_name'], "dummy_member")
            self.assertEqual(qs['password'], "dummy_password")
            self.assertEqual(qs['seconds'], '30')
            # c should be replaced because latin-1 can't encode that and Live365 likes latin-1
            self.assertEqual(qs['title'], 'song')
            self.assertEqual(qs['album'], 'album')
            self.assertEqual(qs['artist'], 'artist')
            return True

        fake_urlopen = (fudge.Fake('urlopen', expect_call=True)
                                .with_args(arg.passes_test(inspect_request)))

        fake_response = (fake_urlopen
                                .returns_fake()
                                .has_attr(code='200')
                                .provides('read')
                                .returns("<service response>"))

        with fudge.patched_context(playlists.tasks.urllib2, "urlopen", fake_urlopen):
            resp = self.client.post(reverse('playlists.send_track_to_live365'), {
                'id': self.track.key()
            })

        fudge.verify()

    def test_create_non_existant_track(self):
        key = self.track.key()
        self.track.delete() # make it non-existant
        resp = self.client.post(reverse('playlists.send_track_to_live365'), {
            'id': key
        })
        self.assertEqual(resp.status_code, 200)
开发者ID:CDMirel,项目名称:chirpradio,代码行数:104,代码来源:test_views.py


注:本文中的playlists.models.PlaylistTrack.delete方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。