Пример #1
0
	def test_remove_playlist_bookmark_bad_request(self):
		user_steam_id, user_id = self._create_steam_user('user_name')
		video_id = db.add_twitch_video(
				'video_name', 99, 'archive_id', 'video_file_url', 'link_url')
		bookmark_id = db.add_video_bookmark(user_id, video_id, 'comment', 33)
		playlist_id = db.create_playlist(user_id, 'playlist_name', now=self.now)
		db.add_playlist_bookmark(user_id, playlist_id, bookmark_id, now=self.now)

		# Assert that the request fails with a missing client identifier.
		with app.test_client() as client:
			response = client.post('/remove_playlist_bookmark',
					data={'playlist_id': playlist_id, 'bookmark_id': bookmark_id})
			self._assert_not_authorized(response)

		# Assert that the request fails with a missing playlist identifier.
		with app.test_client() as client:
			self._add_client_id(client, user_id)
			response = client.post('/remove_playlist_bookmark', data={'bookmark_id': bookmark_id})
			self._assert_ajax_failure(response)

		# Assert that the request fails with a missing bookmark identifier.
		with app.test_client() as client:
			self._add_client_id(client, user_id)
			response = client.post('/remove_playlist_bookmark', data={'playlist_id': playlist_id})
			self._assert_ajax_failure(response)
Пример #2
0
def show_twitch_video(archive_id):
	try:
		client_id = _get_client_id()
		displayed_video = db.get_displayed_twitch_video(client_id, archive_id)
		return flask.render_template('twitch_video.html', displayed_video=displayed_video)
	except db.DbException as e:
		# The video was not found, so go retrieve its JSON from Twitch.
		pass
	
	try:
		twitch_video = download_twitch_video_by_archive_id(archive_id)
	except Exception as e:
		# The video could not be retrieved, so display an error message.
		return flask.render_template('twitch_video.html', displayed_video=None)

	video_id = db.add_twitch_video(
			twitch_video.title,
			twitch_video.length,
			twitch_video.archive_id,
			twitch_video.video_file_url,
			twitch_video.link_url)
	displayed_video = db.DisplayedTwitchVideo(
			video_id,
			twitch_video.title,
			twitch_video.length,
			(),
			twitch_video.archive_id,
			twitch_video.video_file_url,
			twitch_video.link_url)
	return flask.render_template('twitch_video.html', displayed_video=displayed_video)
Пример #3
0
	def test_remove_video_bookmark(self):
		user_steam_id, user_id = self._create_steam_user('user_name')
		video_id = db.add_twitch_video(
				'video_name', 99, 'archive_id', 'video_file_url', 'link_url')
		bookmark_id = db.add_video_bookmark(user_id, video_id, 'comment', 33)

		with app.test_client() as client:
			self._add_client_id(client, user_id)
			response = client.post('/remove_video_bookmark', data={'bookmark_id': bookmark_id})
			self._assert_ajax_success(response)
Пример #4
0
	def test_show_playlist(self):
		user_steam_id, user_id = self._create_steam_user('user_name')
		video_id = db.add_twitch_video(
				'video_name', 99, 'archive_id', 'video_file_url', 'link_url')
		bookmark_id = db.add_video_bookmark(user_id, video_id, 'comment', 33)
		playlist_id = db.create_playlist(user_id, 'playlist_name', now=self.now)
		db.add_playlist_bookmark(user_id, playlist_id, bookmark_id, now=self.now)

		# Get the playlist.
		with app.test_client() as client:
			response = client.get('/playlist/%s' % playlist_id)
			self.assertEqual(requests.codes.ok, response.status_code)
Пример #5
0
	def test_vote_bookmark_thumb_up_bad_request(self):
		user_steam_id, user_id = self._create_steam_user('user_name')
		video_id = db.add_twitch_video(
				'video_name', 99, 'archive_id', 'video_file_url', 'link_url')
		bookmark_id = db.add_video_bookmark(user_id, video_id, 'comment', 33)
		client_steam_id, client_id = self._create_steam_user('client_name')

		# Assert that the request fails with a missing client identifier.
		with app.test_client() as client:
			response = client.post('/vote_bookmark_thumb_up', data={'bookmark_id': bookmark_id})
			self._assert_not_authorized(response)

		# Assert that the request fails with a missing bookmark identifier.
		with app.test_client() as client:
			self._add_client_id(client, client_id)
			response = client.post('/vote_bookmark_thumb_up')
			self._assert_ajax_failure(response)