# Path: montanha/views.py
# def show_index(request, filter_spec):
# 
#     c = {}
# 
#     if filter_spec:
#         institution, _ = parse_filter(filter_spec)
#         if not institution:
#             raise Http404
#         legislatures = institution.legislature_set.order_by('-date_start').all()
#         c['legislatures'] = [l for l in legislatures
#                              if Expense.objects.filter(mandate__legislature=l).count()]
#         c['img'] = institution.siglum.lower() + '.png'
#         return new_render(request, filter_spec, 'institution.html', c)
# 
#     return new_render(request, filter_spec, 'index.html', c)
# 
# def show_robots_txt(request):
#     return HttpResponse('User-Agent: *\nAllow: /\n')
# 
# Path: montanha/tests/fixtures.py
# class InstitutionFactory(factory.django.DjangoModelFactory):
#     class Meta:
#         model = Institution
# 
#     name = factory.Sequence(lambda t: 'name-{0}'.format(t))
#     siglum = factory.Sequence(lambda t: 'siglum-{0}'.format(t))


from django.test import TestCase
from django.test.client import RequestFactory
from montanha.views import show_index, show_robots_txt
from montanha.tests.fixtures import InstitutionFactory
#  License, or (at your option) any later version.
#
#  This program is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#  GNU Affero General Public License for more details.
#
#  You should have received a copy of the GNU Affero General Public License
#  along with this program.  If not, see <http://www.gnu.org/licenses/>.




class MontanhaViewTest(TestCase):
    def setUp(self):
        self.factory = RequestFactory()

    def test_render_index_without_institution(self):
        try:
            request = self.factory.get('/')
            response = show_index(request)
        except TypeError as e:
            response = None
            msg = 'show_index() takes exactly 2 arguments (1 given)'
            self.assertEqual(e.message, msg)

        self.assertEqual(response, None)

    def test_render_index_with_empty_institution(self):
        request = self.factory.get('/')

# Path: montanha/views.py
# def show_index(request, filter_spec):
# 
#     c = {}
# 
#     if filter_spec:
#         institution, _ = parse_filter(filter_spec)
#         if not institution:
#             raise Http404
#         legislatures = institution.legislature_set.order_by('-date_start').all()
#         c['legislatures'] = [l for l in legislatures
#                              if Expense.objects.filter(mandate__legislature=l).count()]
#         c['img'] = institution.siglum.lower() + '.png'
#         return new_render(request, filter_spec, 'institution.html', c)
# 
#     return new_render(request, filter_spec, 'index.html', c)
# 
# def show_robots_txt(request):
#     return HttpResponse('User-Agent: *\nAllow: /\n')
# 
# Path: montanha/tests/fixtures.py
# class InstitutionFactory(factory.django.DjangoModelFactory):
#     class Meta:
#         model = Institution
# 
#     name = factory.Sequence(lambda t: 'name-{0}'.format(t))
#     siglum = factory.Sequence(lambda t: 'siglum-{0}'.format(t))


# Path: montanha/tests/test_views.py
from django.test import TestCase
from django.test.client import RequestFactory
from montanha.views import show_index, show_robots_txt
from montanha.tests.fixtures import InstitutionFactory

#  License, or (at your option) any later version.
#
#  This program is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#  GNU Affero General Public License for more details.
#
#  You should have received a copy of the GNU Affero General Public License
#  along with this program.  If not, see <http://www.gnu.org/licenses/>.




class MontanhaViewTest(TestCase):
    def setUp(self):
        self.factory = RequestFactory()

    def test_render_index_without_institution(self):
        try:
            request = self.factory.get('/')
            response = show_index(request)
        except TypeError as e:
            response = None
            msg = 'show_index() takes exactly 2 arguments (1 given)'
            self.assertEqual(e.message, msg)

        self.assertEqual(response, None)

    def test_render_index_with_empty_institution(self):
        request = self.factory.get('/')

        response = show_index(request, '')