Пример #1
0
    def test_pick_random(self):
        t1 = SimpleText.objects.create(text="An old silent pond... A frog jumps into the pond. Splash! Silence again hello the world is on the word for the win in case there is a word with out the loss of the win")        
        HaikuModel.objects.all_from_text(t1, source=t1)

        t2 = SimpleText.objects.create(text="Watch for the sunrise, and in a split second and there goes the boat across the horizon")
        HaikuModel.objects.all_from_text(t2, source=t2)

        assert HaikuModel.objects.count() > 0

        h = pick_random(HaikuModel)
        assert h.pk is not None

        assert HaikuModel.objects.filter(is_composite=True).count() == 0

        compose_haikus('1,2,1', source=t1, quality_threshold=0, count=10)

        assert HaikuModel.objects.filter(is_composite=True).count() > 1
Пример #2
0
def munge(request):
    haikus = []
    if request.POST:
        f = ComposerForm(request.POST)
        if f.is_valid():
            haikus = compose_haikus(**f.cleaned_data)
    else:
        f = ComposerForm(initial=dict(pattern="1,1,2", count=5, quality_threshold=0, debug='0', video=request.GET.get('video', None)))
    return render_to_response("django_haikus/munge.html", { 'haikus': haikus, 'form': f }, context_instance=RC(request))
Пример #3
0
 def handle(self, *args, **options):
     print compose_haikus(**options)