From: Guillaume Pellerin Date: Wed, 18 Mar 2015 22:37:07 +0000 (+0100) Subject: Add boilerplate with simple test sounds X-Git-Tag: 1.6a^2~48^2~3 X-Git-Url: https://git.parisson.com/?a=commitdiff_plain;h=3ed9dd0ca03216311771cda5f9cd3eb954a14d4f;p=telemeta.git Add boilerplate with simple test sounds --- diff --git a/telemeta/management/commands/telemeta-test-boilerplate.py b/telemeta/management/commands/telemeta-test-boilerplate.py new file mode 100644 index 00000000..c5e9559d --- /dev/null +++ b/telemeta/management/commands/telemeta-test-boilerplate.py @@ -0,0 +1,36 @@ +from optparse import make_option +from django.conf import settings +from django.core.management.base import BaseCommand, CommandError +from django.contrib.auth.models import User +from django.template.defaultfilters import slugify + +import os +from telemeta.models import * +from timeside.core.tools.test_samples import generateSamples + + +class Command(BaseCommand): + help = "Setup and run a boilerplate for testing" + + code = 'Tests' + + def handle(self, *args, **options): + # NOT for production + # self.processor_cleanup() + # self.result_cleanup() + + media_dir = 'items' + os.sep + 'tests' + samples_dir = settings.MEDIA_ROOT + media_dir + samples = generateSamples(samples_dir=samples_dir) + + collection, c = MediaCollection.objects.get_or_create(title=self.code, + code=self.code) + + for sample in samples.iteritems(): + filename, path = sample + title = os.path.splitext(filename)[0] + path = media_dir + os.sep + filename + item, c = MediaItem.objects.get_or_create(title=title, + code=self.code + '-' + slugify(filename), + file=path, collection=collection) +