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


Python PlaylistTrack.put方法代码示例

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


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

示例1: test_recent_tracks

# 需要导入模块: from playlists.models import PlaylistTrack [as 别名]
# 或者: from playlists.models.PlaylistTrack import put [as 别名]
 def test_recent_tracks(self):
     playlist = ChirpBroadcast()
     selector = create_dj()
     track = PlaylistTrack(
         selector=selector,
         playlist=playlist,
         freeform_artist_name="Autechre",
         freeform_album_title="Amber",
         freeform_track_title="Ember"
     )
     track.put()
     time.sleep(0.4)
     track = PlaylistTrack(
         selector=selector,
         playlist=playlist,
         freeform_artist_name="The Meters",
         freeform_album_title="Chicken Strut",
         freeform_track_title="Hand Clapping Song"
     )
     track.put()
     
     recent_tracks = [t for t in playlist.recent_tracks]
     self.assertEqual(recent_tracks[0].track_title,
         "Hand Clapping Song")
     self.assertEqual(recent_tracks[1].track_title,
         "Ember")
开发者ID:BubbleTouchSoftware,项目名称:chirpradio,代码行数:28,代码来源:test_models.py

示例2: bootstrap

# 需要导入模块: from playlists.models import PlaylistTrack [as 别名]
# 或者: from playlists.models.PlaylistTrack import put [as 别名]
def bootstrap(request):
    # Don't create dummy playlist tracks if playlist tracks already exist!
    pl_tracks = PlaylistTrack.all().fetch(1)
    if len(pl_tracks) > 0:
        return HttpResponse(status=404)

    playlist = ChirpBroadcast()

    minutes = 0
    tracks = Track.all().fetch(100)
    for track in tracks:
        pl_track = PlaylistTrack(
            playlist=playlist,
            selector=request.user,
            established=datetime.now() - timedelta(minutes=minutes),
            artist=track.album.album_artist,
            album=track.album,
            track=track,
        )
        pl_track.put()
        if minutes > 0 and minutes % 25 == 0:
            pl_break = PlaylistBreak(playlist=playlist, established=datetime.now() - timedelta(minutes=minutes - 1))
            pl_break.put()
        minutes += 5

    return HttpResponseRedirect("/playlists/")
开发者ID:kumar303,项目名称:chirpradio,代码行数:28,代码来源:views.py

示例3: test_cannot_delete_someone_elses_track

# 需要导入模块: from playlists.models import PlaylistTrack [as 别名]
# 或者: from playlists.models.PlaylistTrack import put [as 别名]
    def test_cannot_delete_someone_elses_track(self):
        other_user = User(email="[email protected]")
        other_user.roles.append(auth.roles.DJ)
        other_user.put()
        time.sleep(0.4)

        other_track = PlaylistTrack(
                    playlist=self.playlist,
                    selector=other_user,
                    freeform_artist_name="Peaches",
                    freeform_track_title="Rock Show",)
        other_track.put()

        with fudge.patched_context(playlists.tasks, "_fetch_url", stub_fetch_url):
            resp = self.client.get(reverse('playlists_delete_event',
                                            args=[other_track.key()]))

        self.assertRedirects(resp, reverse('playlists_landing_page'))
        # simulate the redirect:
        resp = self.client.get(reverse('playlists_landing_page'))

        # should be no change:
        context = resp.context[0]
        tracks = [t.artist_name for t in context['playlist_events']]
        self.assertEquals(tracks, ["Peaches", "Steely Dan"])
开发者ID:CDMirel,项目名称:chirpradio,代码行数:27,代码来源:test_views.py

示例4: test_track_by_free_entry

# 需要导入模块: from playlists.models import PlaylistTrack [as 别名]
# 或者: from playlists.models.PlaylistTrack import put [as 别名]
 def test_track_by_free_entry(self):
     selector = create_dj()
     playlist = ChirpBroadcast()
     track = PlaylistTrack(
         selector=selector,
         playlist=playlist,
         freeform_artist_name="Stevie Wonder",
         freeform_album_title="Talking Book",
         freeform_track_title='You Are The Sunshine Of My Life',
         freeform_label='Warner Bros.',
         notes="This track is a bit played out but it still has some nice melodies"
     )
     track.put()
     self.assertEqual(track.artist_name, "Stevie Wonder")
     self.assertEqual(track.album_title, "Talking Book")
     self.assertEqual(track.album_title_display, "Talking Book")
     self.assertEqual(track.track_title, "You Are The Sunshine Of My Life")
     self.assertEqual(track.label, "Warner Bros.")
     self.assertEqual(track.label_display, "Warner Bros.")
     self.assertEqual(track.notes, 
             "This track is a bit played out but it still has some nice melodies")
             
     # for sanity, not real tests:
     self.assertEqual(
         track.established_display.timetuple()[0:2],
         datetime.datetime.now().timetuple()[0:2])
     self.assertEqual(
         track.modified_display.timetuple()[0:2],
         datetime.datetime.now().timetuple()[0:2])
开发者ID:BubbleTouchSoftware,项目名称:chirpradio,代码行数:31,代码来源:test_models.py

示例5: make_track

# 需要导入模块: from playlists.models import PlaylistTrack [as 别名]
# 或者: from playlists.models.PlaylistTrack import put [as 别名]
 def make_track():
     playlist = ChirpBroadcast()
     track = PlaylistTrack(
         selector=selector,
         playlist=playlist,
         album=self.talking_book,
         track=self.tracks['You Are The Sunshine Of My Life']
     )
     track.put()
开发者ID:BubbleTouchSoftware,项目名称:chirpradio,代码行数:11,代码来源:test_models.py

示例6: create_track

# 需要导入模块: from playlists.models import PlaylistTrack [as 别名]
# 或者: from playlists.models.PlaylistTrack import put [as 别名]
 def create_track(artist, album, track, label):
     track = PlaylistTrack(
                 playlist=playlist,
                 selector=selector,
                 freeform_artist_name=artist,
                 freeform_album_title=album,
                 freeform_track_title=track,
                 freeform_label=label)
     track.put()
     return track
开发者ID:CDMirel,项目名称:chirpradio,代码行数:12,代码来源:test_reports.py

示例7: test_partial_track_by_free_entry

# 需要导入模块: from playlists.models import PlaylistTrack [as 别名]
# 或者: from playlists.models.PlaylistTrack import put [as 别名]
 def test_partial_track_by_free_entry(self):
     selector = create_dj()
     playlist = ChirpBroadcast()
     track = PlaylistTrack(
         selector=selector,
         playlist=playlist,
         freeform_artist_name="Stevie Wonder",
         freeform_track_title='You Are The Sunshine Of My Life'
     )
     track.put()
     self.assertEqual(track.album_title_display, "[Unknown Album]")
     self.assertEqual(track.label_display, "[Unknown Label]")
开发者ID:BubbleTouchSoftware,项目名称:chirpradio,代码行数:14,代码来源:test_models.py

示例8: test_different_tracks

# 需要导入模块: from playlists.models import PlaylistTrack [as 别名]
# 或者: from playlists.models.PlaylistTrack import put [as 别名]
 def test_different_tracks(self):
     self.count()
     new_trk = PlaylistTrack(
         playlist=self.track.playlist,
         selector=self.track.selector,
         freeform_artist_name='Prince',
         freeform_album_title='Purple Rain',
         freeform_track_title='When Doves Cry')
     new_trk.put()
     self.count(track_key=new_trk.key())
     count = PlayCount.all()[0]
     track_ids = [str(w.key()) for w in PlayCount.all()]
     assert track_ids[0] != track_ids[1], (
         'Different artist/albums cannot have the same key')
开发者ID:CDMirel,项目名称:chirpradio,代码行数:16,代码来源:test_views.py

示例9: test_count_different_track

# 需要导入模块: from playlists.models import PlaylistTrack [as 别名]
# 或者: from playlists.models.PlaylistTrack import put [as 别名]
 def test_count_different_track(self):
     self.count()
     # Copy the same artist/track into a new track.
     new_trk = PlaylistTrack(
         playlist=self.track.playlist,
         selector=self.track.selector,
         freeform_artist_name=self.track.freeform_artist_name,
         freeform_album_title=self.track.freeform_album_title,
         freeform_track_title='Another track from the album')
     new_trk.put()
     self.count(track_key=new_trk.key())
     count = PlayCount.all()[0]
     eq_(count.artist_name, self.track.freeform_artist_name)
     eq_(count.album_title, self.track.freeform_album_title)
     eq_(count.label, self.track.label)
     eq_(count.play_count, 2)
开发者ID:CDMirel,项目名称:chirpradio,代码行数:18,代码来源:test_views.py

示例10: test_track_by_references

# 需要导入模块: from playlists.models import PlaylistTrack [as 别名]
# 或者: from playlists.models.PlaylistTrack import put [as 别名]
 def test_track_by_references(self):
     selector = create_dj()
     playlist = ChirpBroadcast()
     track = PlaylistTrack(
         selector=selector,
         playlist=playlist,
         artist=self.stevie,
         album=self.talking_book,
         track=self.tracks['You Are The Sunshine Of My Life']
     )
     track.put()
     self.assertEqual(track.artist_name, "Stevie Wonder")
     self.assertEqual(track.artist, self.stevie)
     self.assertEqual(track.album_title, "Talking Book")
     self.assertEqual(track.album, self.talking_book)
     self.assertEqual(track.track_title, "You Are The Sunshine Of My Life")
     self.assertEqual(track.track, self.tracks['You Are The Sunshine Of My Life'])
开发者ID:BubbleTouchSoftware,项目名称:chirpradio,代码行数:19,代码来源:test_models.py

示例11: test_chirp_playlist_key

# 需要导入模块: from playlists.models import PlaylistTrack [as 别名]
# 或者: from playlists.models.PlaylistTrack import put [as 别名]
    def test_chirp_playlist_key(self):
        playlist_key = chirp_playlist_key()

        track = PlaylistTrack(
            selector=create_dj(),
            playlist=playlist_key,
            freeform_artist_name="Stevie Wonder",
            freeform_album_title="Talking Book",
            freeform_track_title='You Are The Sunshine Of My Life',
            freeform_label='Warner Bros.',
        )
        track.put()

        trk = PlaylistTrack.all().filter('playlist =', playlist_key)
        self.assertEqual(trk[0].artist_name, 'Stevie Wonder')
        playlist_key = chirp_playlist_key()  # from cache
        trk = PlaylistTrack.all().filter('playlist =', playlist_key)
        self.assertEqual(trk[0].artist_name, 'Stevie Wonder')
开发者ID:BubbleTouchSoftware,项目名称:chirpradio,代码行数:20,代码来源:test_models.py

示例12: test_delete_link_appears_for_current_user

# 需要导入模块: from playlists.models import PlaylistTrack [as 别名]
# 或者: from playlists.models.PlaylistTrack import put [as 别名]
    def test_delete_link_appears_for_current_user(self):
        resp = self.client.get(reverse('playlists_landing_page'))
        assert '[delete]' in resp.content

        for track in PlaylistTrack.all():
            track.delete()

        other_user = User(email="[email protected]")
        other_user.roles.append(auth.roles.DJ)
        other_user.put()
        other_track = PlaylistTrack(
                    playlist=self.playlist,
                    selector=other_user,
                    freeform_artist_name="Peaches",
                    freeform_track_title="Rock Show")
        other_track.put()

        resp = self.client.get(reverse('playlists_landing_page'))
        assert '[delete]' not in resp.content
开发者ID:CDMirel,项目名称:chirpradio,代码行数:21,代码来源:test_views.py

示例13: test_freeform_compilation

# 需要导入模块: from playlists.models import PlaylistTrack [as 别名]
# 或者: from playlists.models.PlaylistTrack import put [as 别名]
 def test_freeform_compilation(self):
     stevie, talking_book, tracks = create_stevie_wonder_album_data()
     talking_book.is_compilation = True
     talking_book.put()
     for artist, track in (('Stevie Wonder', 'Superstition'),
                           ('Stevie Wonder', 'Big Brother')):
         new_trk = PlaylistTrack(
             playlist=self.track.playlist,
             selector=self.track.selector,
             freeform_album_title='Talking Book',
             freeform_artist_name=artist,
             freeform_track_title=track,
             freeform_label='...')
         new_trk.put()
         self.count(track_key=new_trk.key())
     res = self.snapshot()
     eq_(res.status_code, 200)
     snap = PlayCountSnapshot.all()[0]
     eq_(snap.play_count, 2)
     eq_(snap.artist_name, 'Various')
     eq_(snap.album_title, 'Talking Book')
开发者ID:CDMirel,项目名称:chirpradio,代码行数:23,代码来源:test_views.py

示例14: test_report_ignores_reference_errors

# 需要导入模块: from playlists.models import PlaylistTrack [as 别名]
# 或者: from playlists.models.PlaylistTrack import put [as 别名]
 def test_report_ignores_reference_errors(self):
     selector = self.get_selector()
     playlist = ChirpBroadcast()
     stevie, talking_book, tracks = create_stevie_wonder_album_data()
     track = PlaylistTrack(
                 playlist=playlist, 
                 selector=selector,
                 artist=stevie,
                 album=talking_book,
                 track=tracks['You Are The Sunshine Of My Life'],
                 freeform_label='Motown')
     track.put()
     
     # simulate an integrity error.
     # it is unlikely but happened to us after a bad data import.
     stevie.delete()
     talking_book.delete()
     
     from_date = datetime.date.today() - timedelta(days=1)
     to_date = datetime.date.today() + timedelta(days=1)
     
     response = self.client.post(reverse('playlists_report'), {
         'from_date': from_date,
         'to_date': to_date,
         'download': 'Download'
     })
     
     self.assertEquals(response['Content-Type'], 'text/csv; charset=utf-8')
     
     report = csv.reader(StringIO(response.content))
     self.assertEquals(
         ['from_date', 'to_date', 'album_title', 'artist_name', 'label',
          'play_count', 'heavy_rotation', 'light_rotation'],
         report.next())
     self.assertEquals(
         [str(from_date), str(to_date), 
         '__bad_reference__', '__bad_reference__', 'Motown', '1',
         '0', '0'],
         report.next())
开发者ID:CDMirel,项目名称:chirpradio,代码行数:41,代码来源:test_reports.py

示例15: test_incomplete_track

# 需要导入模块: from playlists.models import PlaylistTrack [as 别名]
# 或者: from playlists.models.PlaylistTrack import put [as 别名]
    def test_incomplete_track(self):
        selector = self.get_selector()
        playlist = ChirpBroadcast()
        track = PlaylistTrack(
                    playlist=playlist,
                    selector=selector,
                    freeform_artist_name="Squarepusher",
                    freeform_track_title="Port Rhombus")
        track.put()

        with fudge.patched_context(playlists.tasks, "_fetch_url", stub_fetch_url):
            resp = self.client.post(reverse('playlists_add_event'), {
                'artist': 'Julio Iglesias',
                'album': 'Mi Amore'
            })
        # self.assertNoFormErrors(resp)
        context = resp.context[0]
        self.assertEqual(context['form'].errors.as_text(),
            "* song\n  * Please enter the song title.\n* label\n  * Please enter the label.")
        assert 'Please enter the label.' in resp.content
        tracks = [t for t in context['playlist_events']]
        self.assertEquals(tracks[0].artist_name, "Squarepusher")
        self.assertEquals(tracks[0].track_title, "Port Rhombus")
开发者ID:CDMirel,项目名称:chirpradio,代码行数:25,代码来源:test_views.py


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