本文整理汇总了Python中playlists.models.PlaylistTrack.established方法的典型用法代码示例。如果您正苦于以下问题:Python PlaylistTrack.established方法的具体用法?Python PlaylistTrack.established怎么用?Python PlaylistTrack.established使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类playlists.models.PlaylistTrack
的用法示例。
在下文中一共展示了PlaylistTrack.established方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_view_shows_3_hours_of_tracks
# 需要导入模块: from playlists.models import PlaylistTrack [as 别名]
# 或者: from playlists.models.PlaylistTrack import established [as 别名]
def test_view_shows_3_hours_of_tracks(self):
selector = self.get_selector()
playlist = ChirpBroadcast()
track = PlaylistTrack(
playlist=playlist,
selector=selector,
freeform_artist_name="Steely Dan",
freeform_album_title="Aja",
freeform_track_title="Peg")
track.put()
# sleep to workaround microtime issues in Windows App Engine SDK
time.sleep(0.4)
track = PlaylistTrack(
playlist=playlist,
selector=selector,
freeform_artist_name="Def Leoppard",
freeform_album_title="Pyromania",
freeform_track_title="Photograph")
track.put()
time.sleep(0.4)
track = PlaylistTrack(
playlist=playlist,
selector=selector,
freeform_artist_name="Freestyle Fellowship",
freeform_album_title="To Whom It May Concern",
freeform_track_title="Five O'Clock Follies")
# older than 3 hours:
track.established = datetime.datetime.now() - datetime.timedelta(hours=3, minutes=2)
track.put()
resp = self.client.get(reverse('playlists_landing_page'))
context = resp.context[0]
tracks = [t for t in context['playlist_events']]
self.assertEquals(tracks[0].track_title, "Photograph")
self.assertEquals(tracks[1].track_title, "Peg")
self.assertEquals(len(tracks), 2, "tracks older than 3 hours were not hidden")