def test_create_duplicates(self): ''' Tests raise exception with trying to create duplicates. ''' configure_for_unittest() from model import Video from neomodel import UniqueProperty video1 = Video(link='https://vk.com/blablabla').save() video2 = Video(link='vk.com/blablabla') with self.assertRaises(UniqueProperty): video2.save()
def upload(): if 'video' not in request.files: return json_error("Video file not found") video_file = request.files['video'] filename = secure_filename(video_file.filename) ext = filename.split('.')[-1] new_filename = generate_random_string() + '.' + ext video_file.save(os.path.join(app.config['UPLOAD_DIR'], new_filename)) video = Video(filename=new_filename) video.save() return jsonify(video.to_dict())