Ejemplo n.º 1
0
 def test_upload_audio_with_wrong_extension(self):
     data, _ = self.create_audio_form_data(u"tone.mp3", "audio/mpeg")
     audiofile = SimpleUploadedFile(u"tone.mpe",
                                    "file content",
                                    content_type="audio/mpeg")
     form = AudioForm(data, {"audio": audiofile}, user=self.user)
     self.assertFalse(form.is_valid())
Ejemplo n.º 2
0
    def test_upload_audio_with_wrong_extension(self):
        data, _ = self.create_audio_form_data("tone.mp3", "audio/mpeg")
        audiofile = SimpleUploadedFile("tone.mpe", "file content",
                                       content_type="audio/mpeg")
        form = AudioForm(data, {"audio":audiofile}, user=self.user)

        self.assertFalse(form.is_valid())
        self.assertTrue("extension" in form.errors.as_ul())
Ejemplo n.º 3
0
    def test_edit_audio(self):
        data, audiofile = self.create_audio_form_data("tone.mp3", "audio/mpeg")
        form = AudioForm(data, {"audio": audiofile}, user=self.user)
        self.assertTrue(form.is_valid())
        audio = form.save()

        data['description'] = "new desc"
        edit_form = AudioForm(data, instance=audio, user=self.user)
        self.assertTrue(form.is_valid())
        edit_form.save()
Ejemplo n.º 4
0
def audio_create_update(request, slug=None):
    instance = get_object_or_404(Audio, slug=slug) if slug else None
    if request.method == "POST":
        form = AudioForm(request.POST, request.FILES, user=request.user,
                         instance=instance)
        if form.is_valid():
            project = form.cleaned_data.get("project")
            project = get_object_or_404(Project, pk=project.pk)
            audio = form.save()
            project.audios.add(audio)
            return redirect("audio-detail", slug=audio.slug)
    else:
        form = AudioForm(user=request.user, instance=instance)

    return render(request, "audio/audio_form.html", {
        'form': form,
        'object': instance,
    })
Ejemplo n.º 5
0
    def test_edit_audio(self):
        data, audiofile = self.create_audio_form_data("tone.mp3", "audio/mpeg")
        form = AudioForm(data, {"audio": audiofile}, user=self.user)
        self.assertTrue(form.is_valid())
        audio = form.save()

        data['description'] = "new desc"
        edit_form = AudioForm(data, instance=audio, user=self.user)
        self.assertTrue(form.is_valid())
        edit_form.save()
Ejemplo n.º 6
0
def set_audio():
    fx_config = get_current_fx_data()
    form = AudioForm()

    if form.validate_on_submit():
        flash("Effect params accepted")
        fx_config["effect_params"]["audio"]["bass_bins"] = int(
            form.bass_bins.data)
        fx_config["effect_params"]["audio"]["middle_bins"] = int(
            form.middle_bins.data)
        fx_config["effect_params"]["audio"]["high_bins"] = int(
            form.high_bins.data)
        set_current_fx_data(fx_config)
        return redirect(url_for("index"))
    else:
        form.bass_bins.data = str(
            fx_config["effect_params"]["audio"]["bass_bins"])
        form.middle_bins.data = str(
            fx_config["effect_params"]["audio"]["middle_bins"])
        form.high_bins.data = str(
            fx_config["effect_params"]["audio"]["high_bins"])

        return render_template("audio.html", form=form)
Ejemplo n.º 7
0
def audio_create_update(request, slug=None):
    instance = get_object_or_404(Audio, slug=slug) if slug else None
    if request.method == "POST":
        form = AudioForm(request.POST,
                         request.FILES,
                         user=request.user,
                         instance=instance)
        if form.is_valid():
            project = form.cleaned_data.get("project")
            project = get_object_or_404(Project, pk=project.pk)
            audio = form.save()
            project.audios.add(audio)
            return redirect("audio-detail", slug=audio.slug)
    else:
        form = AudioForm(user=request.user, instance=instance)

    return render(request, "audio/audio_form.html", {
        'form': form,
        'object': instance,
    })
Ejemplo n.º 8
0
 def test_upload_ogg(self):
     data, audiofile = self.create_audio_form_data(u"tone.ogg",
                                                   "audio/mpeg")
     form = AudioForm(data, {"audio": audiofile}, user=self.user)
     self.assertTrue(form.is_valid())
     audio = form.save()
Ejemplo n.º 9
0
 def test_upload_audio(self):
     data, audiofile = self.create_audio_form_data("tone.mp3", "audio/mpeg")
     form = AudioForm(data, {"audio":audiofile}, user=self.user)
     self.assertTrue(form.is_valid())
     audio = form.save()