# -*- encoding: utf-8 -*-

import pytest
from django.contrib.contenttypes.models import ContentType
from django.template.base import Template
from django.template.context import RequestContext
from model_mommy import mommy

from flexible_reports.models.datasource import Datasource
from flexible_reports.models.report import Report
from test_app.models import MyTestFoo


@pytest.mark.django_db
def test_templatetags_flexible(rf):
    x = "{% load flexible_reports_tags %}{% flexible report %}"

    r = mommy.make(Report)

    request = rf.get('/')
    ctx = RequestContext(request, dict(
        request=request,
        report=r))

    res = Template(x).render(context=ctx)



@pytest.mark.django_db
def test_templatetags_render(rf):
    x = "{% load flexible_reports_tags %}{% render report %}"

    r = mommy.make(Report)

    request = rf.get('/')
    ctx = RequestContext(request, dict(
        request=request,
        report="foobar"))

    res = Template(x).render(context=ctx)
    assert res == "foobar"

@@ -507,32 +507,81 @@
 mmy.make(Report)
+%0A    r.set_base_queryset(MyTestFoo.objects.all())
 %0A%0A    request = 
@@ -721,17 +721,16 @@
 =ctx)%0A%0A%0A
-%0A
 @pytest.
@@ -833,32 +833,32 @@
 der report %25%7D%22%0A%0A
-
     r = mommy.ma
@@ -866,16 +866,84 @@
 e(Report
+, template=%22foobar%22)%0A    r.set_base_queryset(MyTestFoo.objects.all()
 )%0A%0A    r

Fix tests