diff options
| author | Étienne Loks <etienne.loks@iggdrasil.net> | 2016-07-16 20:10:57 +0200 | 
|---|---|---|
| committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2016-07-16 20:10:57 +0200 | 
| commit | d4119bdffd893943263a82813f6b783fda0253dd (patch) | |
| tree | 8e2be9071d39542da68661a27bc402874314798a /archaeological_operations/tests.py | |
| parent | a39f989e9c02bca9e4c3127fde855364f392e3a5 (diff) | |
| parent | 5e7cda4fe8902979dac8a8008908accb8f0bfab4 (diff) | |
| download | Ishtar-d4119bdffd893943263a82813f6b783fda0253dd.tar.bz2 Ishtar-d4119bdffd893943263a82813f6b783fda0253dd.zip | |
Merge branch 'master' into v0.9
Conflicts:
	install/install.sh
Diffstat (limited to 'archaeological_operations/tests.py')
| -rw-r--r-- | archaeological_operations/tests.py | 104 | 
1 files changed, 85 insertions, 19 deletions
| diff --git a/archaeological_operations/tests.py b/archaeological_operations/tests.py index c22cf4b37..5eeeb1808 100644 --- a/archaeological_operations/tests.py +++ b/archaeological_operations/tests.py @@ -1,6 +1,6 @@  #!/usr/bin/env python  # -*- coding: utf-8 -*- -# Copyright (C) 2012-2015 Étienne Loks  <etienne.loks_AT_peacefrogsDOTnet> +# Copyright (C) 2012-2016 Étienne Loks  <etienne.loks_AT_peacefrogsDOTnet>  # This program is free software: you can redistribute it and/or modify  # it under the terms of the GNU Affero General Public License as @@ -29,13 +29,16 @@ from django.core.urlresolvers import reverse  from django.test import TestCase  from django.test.client import Client -from django.contrib.auth.models import User, Permission +from django.contrib.auth.models import Permission  import models +from archaeological_operations import views +  from ishtar_common.models import OrganizationType, Organization, \      ImporterType, IshtarUser, TargetKey  from ishtar_common import forms_common +from ishtar_common.tests import WizardTest, create_superuser, create_user  class ImportOperationTest(TestCase): @@ -416,23 +419,6 @@ class ImportOperationTest(TestCase):                  "recognized in \"%s\"" % (str(not_imported), value)) -def create_superuser(): -    username = 'username4277' -    password = 'dcbqj756456!@%' -    user = User.objects.create_superuser(username, "nomail@nomail.com", -                                         password) -    return username, password, user - - -def create_user(): -    username = 'username678' -    password = 'dcbqj756456!@%' -    user = User.objects.create_user(username, email="nomail2@nomail.com") -    user.set_password(password) -    user.save() -    return username, password, user - -  def create_orga(user):      orga_type, created = OrganizationType.objects.get_or_create(          txt_idx='operator') @@ -626,3 +612,83 @@ class RegisterTest(TestCase, OperationInitTest):          self.assertTrue(json.loads(response.content)['total'] == 1)          response = c.get(reverse('get-administrativeact'), {'indexed': '2'})          self.assertTrue(json.loads(response.content)['total'] == 1) + + +class OperationWizardCreationTest(WizardTest, OperationInitTest, TestCase): +    fixtures = [settings.ROOT_PATH + +                '../fixtures/initial_data-auth-fr.json', +                settings.ROOT_PATH + +                '../ishtar_common/fixtures/initial_data-fr.json', +                settings.ROOT_PATH + +                '../archaeological_files/fixtures/initial_data.json', +                settings.ROOT_PATH + +                '../archaeological_operations/fixtures/initial_data-fr.json'] +    url_name = 'operation_creation' +    wizard_name = 'operation_wizard' +    steps = views.wizard_steps +    form_datas = [( +        # data +        { +            'general-operation_creation': { +                'operation_type': 1,  # preventive diag +                'year': 2016} +        }, +        # ignored +        ('filechoice-operation_creation', +         'preventive-operation_creation', +         'towns-operation_creation', +         'parcels-operation_creation', +         ) +    )] + +    def pre_wizard(self): +        self.operation_number = models.Operation.objects.count() +        super(OperationWizardCreationTest, self).pre_wizard() + +    def post_wizard(self): +        self.assertEqual(models.Operation.objects.count(), +                         self.operation_number + 1) + + +class OperationAdminActWizardCreationTest(WizardTest, OperationInitTest, +                                          TestCase): +    fixtures = [settings.ROOT_PATH + +                '../fixtures/initial_data-auth-fr.json', +                settings.ROOT_PATH + +                '../ishtar_common/fixtures/initial_data-fr.json', +                settings.ROOT_PATH + +                '../archaeological_files/fixtures/initial_data.json', +                settings.ROOT_PATH + +                '../archaeological_operations/fixtures/initial_data-fr.json'] +    url_name = 'operation_administrativeactop' +    wizard_name = 'operation_administrative_act_wizard' +    steps = views.administrativeactop_steps +    form_datas = [[ +        # data +        { +            'selec-operation_administrativeactop': { +            }, +            'administrativeact-operation_administrativeactop': { +                'signature_date': str(datetime.date.today()) +            } +        }, +        # ignored +        [] +    ]] + +    def pre_wizard(self): +        ope = self.get_default_operation() + +        self.number = models.AdministrativeAct.objects.count() + +        data = self.form_datas[0][0] +        data['selec-operation_administrativeactop']['pk'] = ope.pk +        act = models.ActType.objects.filter(intented_to='O').all()[0].pk + +        data['administrativeact-operation_administrativeactop'][ +            'act_type'] = act +        super(OperationAdminActWizardCreationTest, self).pre_wizard() + +    def post_wizard(self): +        self.assertEqual(models.AdministrativeAct.objects.count(), +                         self.number + 1) | 
