def test_commit(self): user = users.find(self.test_user_id) video = videos.find(self.video_id) video._duration = 0 watchtran.begin(user, video) result = watchtran.commit(user, video) self.assertIsNotNone(result)
def test_begin(self): user = users.find(self.test_user_id) video = videos.find(self.video_id) watchtran.begin(user, video) key = self.prefix + self.test_user_id val = self.redis.get(key) self.assertIsNotNone(val)
def test_commit(self): video = videos.find('5129e49971eeccbbcaf90802') video._duration = 0 user = users.find(self.user_id) watchtran.begin(user, video) service_url = '/player/commit.json' data = dict(video_id=video.sysid) with self.app.test_client() as client: with client.session_transaction() as sess: sess['account'] = self.user_id response = post_json(service_url, data, client) response_chances = response['chances'] user = users.find(user.sysid) self.assertEqual(response_chances, 223) self.assertEqual(user.chances, 223)
def show(vidid): g.menu['select_top_menu']['home'] = True user = users.current() render_data = {} if vidid == 'random': render_data['mode'] = 'normal' video = videos.random() watchtran.begin(user, video) else: render_data['mode'] = 'specific' video = videos.find(vidid) # TODO: remove line below watchtran.begin(user, video) if video is None: abort(404) render_data['video'] = video render_data['user_message_size'] = USER_MESSAGE_SIZE scomments = comments.for_screening(video, user) render_data['comments'] = scomments return render_template('player/screening.html', **render_data)
def test_commit_too_early(self): user = users.find(self.test_user_id) video = videos.find(self.video_id) watchtran.begin(user, video) result = watchtran.commit(user, video) self.assertIsNone(result)