From 036808ac9a5d6f1c470c03ab726a6a74eb710dd3 Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Mon, 3 Jul 2017 13:04:01 +0200 Subject: Archaeologivcal files: safely manage is_preventive test if preventive type is not created - show-file test --- archaeological_files/tests.py | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) (limited to 'archaeological_files/tests.py') diff --git a/archaeological_files/tests.py b/archaeological_files/tests.py index 2b0a63af8..82f85e7c9 100644 --- a/archaeological_files/tests.py +++ b/archaeological_files/tests.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- -# Copyright (C) 2010-2015 Étienne Loks +# Copyright (C) 2010-2017 Étienne Loks # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as @@ -17,14 +17,13 @@ # See the file COPYING for details. -""" -Unit tests -""" import datetime import json from django.conf import settings from django.contrib.auth.models import User +from django.core.urlresolvers import reverse +from django.test.client import Client from ishtar_common.tests import TestCase @@ -225,11 +224,19 @@ class FileTest(TestCase, FileInit): # our parcel has no operation attached and should be deleted self.assertEqual(parcel_nb - 1, Parcel.objects.count()) -# class ImporterTest(TestCase): -# def testFormaters(self): -# from archaeological_files import data_importer -# for formater in [data_importer.SurfaceFormater]: -# formater().test() + def test_show(self): + c = Client() + url = 'show-file' + pk = self.item.pk + response = self.client.get(reverse(url, kwargs={'pk': pk})) + self.assertEqual(response.status_code, 200) + # empty content when not allowed + self.assertEqual(response.content, "") + + self.login_as_superuser() + response = self.client.get(reverse(url, kwargs={'pk': pk})) + self.assertEqual(response.status_code, 200) + self.assertIn('class="sheet"', response.content) class FileOperationTest(TestCase, OperationInitTest, FileInit): -- cgit v1.2.3