Example #1
0
    def test_add_complete_repository_folder_path_for_each_added_dossier(self):
        root = create(Builder('repository_root'))
        folder1 = create(Builder('repository').within(root))
        folder1_1 = create(Builder('repository').within(folder1))
        dossier1 = create(Builder('dossier').within(folder1_1))
        folder2 = create(Builder('repository').within(root))
        dossier2 = create(Builder('dossier').within(folder2))
        folder3 = create(Builder('repository').within(root))
        create(Builder('dossier').within(folder3))

        model = Repository()
        model.add_dossier(Dossier(dossier1))

        self.assertEquals(root, model.obj)
        positions = model.positions.values()

        self.assertEquals([folder1], [pos.obj for pos in positions])
        self.assertEquals([folder1_1],
                          [pos.obj for pos in positions[0].positions.values()])

        model.add_dossier(Dossier(dossier2))
        positions = model.positions.values()

        self.assertEquals(set([folder1, folder2]),
                          set([pos.obj for pos in positions]))
    def test_add_descendants_adds_all_subdossiers(self):
        self.login(self.regular_user)

        model = Dossier(self.dossier)
        model._add_descendants()

        self.assertEquals(set([self.subdossier, self.subdossier2]),
                          set([mod.obj for mod in model.dossiers.values()]))
Example #3
0
    def test_add_descendants_adds_all_subdossiers(self):
        self.login(self.regular_user)

        model = Dossier(self.dossier)
        model._add_descendants()

        self.assertEquals(
            set([self.subdossier, self.subdossier2]),
            set([mod.obj for mod in model.dossiers.values()]))
Example #4
0
    def test_add_descendants_adds_also_documents_in_tasks(self):
        dossier = create(Builder('dossier'))
        task = create(Builder('task').within(dossier))
        document = create(Builder('document').within(task))

        model = Dossier(dossier)
        model._add_descendants()

        self.assertEqual(set([document]),
                         set([doc.obj for doc in model.documents.values()]))
Example #5
0
    def test_add_descendants_adds_all_subdossiers(self):
        dossier = create(Builder('dossier'))
        subdossier1 = create(Builder('dossier').within(dossier))
        create(Builder('dossier'))
        subdossier3 = create(Builder('dossier').within(dossier))

        model = Dossier(dossier)
        model._add_descendants()

        self.assertEquals(set([subdossier3, subdossier1]),
                          set([mod.obj for mod in model.dossiers.values()]))
Example #6
0
    def test_add_descendants_adds_also_documents_in_tasks(self):
        dossier = create(Builder('dossier'))
        task = create(Builder('task').within(dossier))
        document = create(Builder('document').within(task))

        model = Dossier(dossier)
        model._add_descendants()

        self.assertEqual(
            set([document]),
            set([doc.obj for doc in model.documents.values()]))
Example #7
0
    def test_add_descendants_adds_all_containing_documents(self):
        dossier = create(Builder('dossier'))
        document1 = create(Builder('document').within(dossier))
        create(Builder('document'))
        document3 = create(Builder('document').within(dossier))

        model = Dossier(dossier)
        model._add_descendants()

        self.assertEquals(set([document1, document3]),
                          set([doc.obj for doc in model.documents.values()]))
Example #8
0
    def test_add_descendants_adds_all_subdossiers(self):
        dossier = create(Builder('dossier'))
        subdossier1 = create(Builder('dossier').within(dossier))
        create(Builder('dossier'))
        subdossier3 = create(Builder('dossier').within(dossier))

        model = Dossier(dossier)
        model._add_descendants()

        self.assertEquals(
            set([subdossier3, subdossier1]),
            set([mod.obj for mod in model.dossiers.values()]))
Example #9
0
    def test_add_descendants_adds_all_containing_documents(self):
        dossier = create(Builder('dossier'))
        document1 = create(Builder('document').within(dossier))
        create(Builder('document'))
        document3 = create(Builder('document').within(dossier))

        model = Dossier(dossier)
        model._add_descendants()

        self.assertEquals(
            set([document1, document3]),
            set([doc.obj for doc in model.documents.values()]))
Example #10
0
    def test_add_descendants_adds_all_containing_documents(self):
        self.login(self.manager)

        model = Dossier(self.dossier)
        model._add_descendants()

        brains = api.content.find(context=self.dossier, depth=1,
                                  portal_type='opengever.document.document')
        expected_documents = set([brain.getObject() for brain in brains])

        self.assertEquals(expected_documents,
                          set([doc.obj for doc in model.documents.values()]))
    def test_add_descendants_adds_all_containing_documents(self):
        self.login(self.manager)

        model = Dossier(self.dossier)
        model._add_descendants()

        brains = api.content.find(context=self.dossier,
                                  depth=1,
                                  portal_type='opengever.document.document')
        expected_documents = set([brain.getObject() for brain in brains])

        self.assertEquals(expected_documents,
                          set([doc.obj for doc in model.documents.values()]))
    def test_complete_tree_representation(self):
        self.login(self.regular_user)

        repo = Repository()
        content = ContentRootFolder('SIP_20101212_FD_10xy')

        models = [Dossier(self.dossier), Dossier(self.inactive_dossier)]
        for dossier_model in models:
            repo.add_dossier(dossier_model)
            content.add_dossier(dossier_model)

        self.assertEquals(2, len(content.folders))
        dossier_model, inactive_dossier_model = content.folders

        # self.dossier
        # two subdossiers, self.subdossier and self.subdossier2
        self.assertEquals(2, len(dossier_model.folders))
        # dossier a contains two files, one for self.document
        # and one automatically generated for self.decided_proposal
        self.assertEquals(2, len(dossier_model.files))
        subdossier_model = dossier_model.folders[0]
        subdossier2_model = dossier_model.folders[1]

        # self.subdossier
        # contains self.subsubdossier
        self.assertEquals(1, len(subdossier_model.folders))
        self.assertEquals(1, len(subdossier_model.files))
        subdocument_model = subdossier_model.files[0]
        self.assertEquals(self.subdocument.get_filename(),
                          subdocument_model.filename)
        self.assertEquals(self.subdocument.file._blob.committed(),
                          subdocument_model.filepath)

        # self.subsubdossier
        subsubdossier_model = subdossier_model.folders[0]
        self.assertEquals([], subsubdossier_model.folders)
        self.assertEquals(1, len(subsubdossier_model.files))

        # self.subdossier2
        self.assertEquals([], subdossier2_model.folders)
        self.assertEquals(0, len(subdossier2_model.files))

        # self.inactive_dossier
        self.assertEquals([], inactive_dossier_model.folders)
        self.assertEquals(1, len(inactive_dossier_model.files))
        inactive_document_model = inactive_dossier_model.files[0]
        self.assertEquals(self.inactive_document.get_filename(),
                          inactive_document_model.filename)
        self.assertEquals(self.inactive_document.file._blob.committed(),
                          inactive_document_model.filepath)
    def test_add_descendants_adds_also_documents_in_tasks(self):
        """If this were implemented it would show up in the test
        test_add_descendants_adds_all_containing_documents
        """
        self.login(self.regular_user)
        dossier = create(Builder('dossier'))
        task = create(Builder('task').within(dossier))
        document = create(Builder('document').within(task))

        model = Dossier(dossier)
        model._add_descendants()

        self.assertEqual(set([document]),
                         set([doc.obj for doc in model.documents.values()]))
Example #14
0
    def test_add_descendants_adds_also_documents_in_tasks(self):
        """If this were implemented it would show up in the test
        test_add_descendants_adds_all_containing_documents
        """
        self.login(self.regular_user)
        dossier = create(Builder('dossier'))
        task = create(Builder('task').within(dossier))
        document = create(Builder('document').within(task))

        model = Dossier(dossier)
        model._add_descendants()

        self.assertEqual(
            set([document]),
            set([doc.obj for doc in model.documents.values()]))
    def test_black_listed_archival_files_are_ignored(self):
        self.toc = ContentRootFolder('FAKE_PATH')
        self.toc.next_file = 3239

        self.login(self.regular_user)

        # Blacklist word files
        api.portal.set_registry_record(
            name='archival_file_conversion_blacklist',
            value=[
                'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
                'application/msword'
            ],
            interface=IDossierResolveProperties)

        dossier = Dossier(self.expired_dossier)
        self.assertEqual(1, len(dossier.documents))

        document = dossier.documents.values()[0]
        folder = Folder(self.toc, dossier, 'FAKE_PATH')

        self.assertEqual(1, len(folder.files))
        self.assertItemsEqual([self.expired_document.file.filename],
                              [file.filename for file in folder.files])
        self.assertEqual(1, len(document.file_refs))
    def test_eroeffnungsdatum_is_start_date(self):
        self.login(self.regular_user)

        binding = Dossier(self.dossier).binding()
        self.assertEquals(
            IDossier(self.dossier).start,
            binding.eroeffnungsdatum.datum.date())
    def test_entstehungszeitraum_is_kein_angabe_when_dossier_is_empty(self):
        self.login(self.regular_user)

        binding = Dossier(self.empty_dossier).binding()
        self.assertEquals(u'keine Angabe',
                          binding.entstehungszeitraum.von.datum)
        self.assertEquals(u'keine Angabe',
                          binding.entstehungszeitraum.bis.datum)
    def test_add_dossier_descendants_as_dossiers(self):
        self.login(self.regular_user)

        dossier_model = Dossier(self.dossier)
        model = Position(self.leaf_repofolder)
        model._add_descendants([dossier_model])

        self.assertEquals([dossier_model], model.dossiers.values())
Example #19
0
    def test_entstehungszeitraum_is_kein_angabe_when_dossier_is_empty(self):
        dossier = create(Builder('dossier'))

        binding = Dossier(dossier).binding()
        self.assertEquals(u'keine Angabe',
                          binding.entstehungszeitraum.von.datum)
        self.assertEquals(u'keine Angabe',
                          binding.entstehungszeitraum.bis.datum)
Example #20
0
    def test_add_dossier_descendants_as_dossiers(self):
        folder = create(Builder('repository'))
        dossier = create(Builder('dossier').within(folder))
        dossier_model = Dossier(dossier)

        model = Position(folder)
        model._add_descendants([dossier_model])

        self.assertEquals([dossier_model], model.dossiers.values())
Example #21
0
    def test_aktenzeichen_is_refernce_number(self):
        folder1 = create(Builder('repository'))
        folder1_7 = create(
            Builder('repository').having(
                reference_number_prefix='7').within(folder1))
        dossier = create(Builder('dossier').within(folder1_7))

        self.assertEquals('Client1 1.7 / 1',
                          Dossier(dossier).binding().aktenzeichen)
    def test_add_complete_repository_folder_path_for_each_added_dossier(self):
        self.login(self.regular_user)
        dossier = create(Builder('dossier').within(self.empty_repofolder))

        model = Repository()
        model.add_dossier(Dossier(self.dossier))

        self.assertEquals(self.repository_root, model.obj)
        positions = model.positions.values()

        self.assertEquals([self.branch_repofolder],
                          [pos.obj for pos in positions])
        self.assertEquals([self.leaf_repofolder],
                          [pos.obj for pos in positions[0].positions.values()])

        model.add_dossier(Dossier(dossier))
        positions = model.positions.values()

        self.assertEquals(set([self.branch_repofolder, self.empty_repofolder]),
                          set([pos.obj for pos in positions]))
Example #23
0
    def test_complete_tree_representation(self):
        root = create(Builder('repository_root'))
        folder = create(Builder('repository').within(root))
        dossier_a = create(Builder('dossier').within(folder))
        subdossier_a = create(Builder('dossier').within(dossier_a))
        document_a = create(
            Builder('document').within(subdossier_a).with_dummy_content())
        dossier_b = create(Builder('dossier').within(folder))
        document_b = create(
            Builder('document').within(dossier_b).with_dummy_content())

        repo = Repository()
        content = ContentRootFolder('SIP_20101212_FD_10xy')

        models = [Dossier(dossier_a), Dossier(dossier_b)]
        for dossier_model in models:
            repo.add_dossier(dossier_model)
            content.add_dossier(dossier_model)

        self.assertEquals(2, len(content.folders))
        dossier_model_a, dossier_model_b = content.folders

        # dossier a
        self.assertEquals(1, len(dossier_model_a.folders))
        subdossier_model = dossier_model_a.folders[0]
        self.assertEquals(1, len(subdossier_model.files))
        file_model_a = subdossier_model.files[0]
        self.assertEquals(u'testdokumant.doc', file_model_a.filename)
        self.assertEquals(document_a.file._blob.committed(),
                          file_model_a.filepath)

        # dossier b
        self.assertEquals([], dossier_model_b.folders)
        self.assertEquals(1, len(dossier_model_b.files))
        file_model_b = dossier_model_b.files[0]
        self.assertEquals(u'testdokumant.doc', file_model_b.filename)
        self.assertEquals(document_b.file._blob.committed(),
                          file_model_b.filepath)
    def test_classification_attributes_and_schutzfrist(self):
        self.login(self.regular_user)

        classification = IClassification(self.dossier)
        classification.privacy_layer = 'privacy_layer_yes'
        classification.public_trial = 'private'
        classification.public_trial_statement = u'Enth\xe4lt sch\xfctzenswerte Daten.'

        binding = Dossier(self.dossier).binding()

        self.assertEquals(u'30', binding.schutzfrist)
        self.assertEquals('unprotected', binding.klassifizierungskategorie)
        self.assertEquals(1, binding.datenschutz)
        self.assertEquals('private', binding.oeffentlichkeitsstatus)
        self.assertEquals(u'Enth\xe4lt sch\xfctzenswerte Daten.',
                          binding.oeffentlichkeitsstatusBegruendung)
Example #25
0
    def test_classification_attributes_and_schutzfrist(self):
        dossier = create(
            Builder('dossier').having(
                custody_period=30,
                classification='unprotected',
                privacy_layer='privacy_layer_yes',
                public_trial='private',
                public_trial_statement=u'Enth\xe4lt sch\xfctzenswerte Daten.'))

        binding = Dossier(dossier).binding()

        self.assertEquals(u'30', binding.schutzfrist)
        self.assertEquals('unprotected', binding.klassifizierungskategorie)
        self.assertEquals(1, binding.datenschutz)
        self.assertEquals('private', binding.oeffentlichkeitsstatus)
        self.assertEquals(u'Enth\xe4lt sch\xfctzenswerte Daten.',
                          binding.oeffentlichkeitsstatusBegruendung)
Example #26
0
    def test_entstehungszeitraum_is_oldest_document_date_to_newest_one(self):
        dossier = create(Builder('dossier'))
        create(
            Builder('document').within(dossier).with_modification_date(
                DateTime(2016, 1, 15)).with_creation_date(DateTime(2014, 3,
                                                                   4)))
        create(
            Builder('document').within(dossier).with_modification_date(
                DateTime(2016, 3, 1)).with_creation_date(DateTime(2015, 1, 1)))
        create(
            Builder('document').within(dossier).with_modification_date(
                DateTime(2016, 12,
                         27)).with_creation_date(DateTime(2016, 1, 1)))

        binding = Dossier(dossier).binding()

        self.assertEquals(date(2014, 3, 4),
                          binding.entstehungszeitraum.von.datum.date())
        self.assertEquals(date(2016, 12, 27),
                          binding.entstehungszeitraum.bis.datum.date())
    def test_document_references_file_and_archival_file(self):
        self.toc = ContentRootFolder('FAKE_PATH')
        self.toc.next_file = 3239

        self.login(self.regular_user)

        dossier = Dossier(self.expired_dossier)
        self.assertEqual(1, len(dossier.documents))
        document = dossier.documents.values()[0]

        folder = Folder(self.toc, dossier, 'FAKE_PATH')

        self.assertEqual(2, len(folder.files))
        self.assertItemsEqual([
            self.expired_document.file.filename,
            self.expired_document.archival_file.filename
        ], [file.filename for file in folder.files])

        self.assertEqual(2, len(document.file_refs))
        self.assertItemsEqual([file.id for file in folder.files],
                              document.file_refs)
Example #28
0
 def test_titel_is_title_in_utf8(self):
     dossier = create(Builder('dossier').titled(u'F\xfchrung'))
     self.assertEquals(u'F\xfchrung', Dossier(dossier).binding().titel)
    def test_titel_is_title_in_unicode(self):
        self.login(self.regular_user)

        self.assertEquals(self.dossier.Title().decode("utf-8"),
                          Dossier(self.dossier).binding().titel)
    def test_aktenzeichen_is_refernce_number(self):
        self.login(self.regular_user)

        self.assertEquals('Client1 1.1 / 1',
                          Dossier(self.dossier).binding().aktenzeichen)
    def test_abschlussdatum_is_end_date(self):
        self.login(self.regular_user)

        binding = Dossier(self.inactive_dossier).binding()
        self.assertEquals(date(2016, 12, 31),
                          binding.abschlussdatum.datum.date())
Example #32
0
 def test_id_is_uid_prefixed_with_a_underscore(self):
     dossier = create(Builder('dossier'))
     self.assertEquals('_fake0000000000000000000000000001',
                       Dossier(dossier).binding().id)
Example #33
0
    def test_abschlussdatum_is_end_date(self):
        dossier = create(Builder('dossier').having(end=date(2016, 11, 6)))

        binding = Dossier(dossier).binding()
        self.assertEquals(date(2016, 11, 6),
                          binding.abschlussdatum.datum.date())
Example #34
0
    def test_eroeffnungsdatum_is_start_date(self):
        dossier = create(Builder('dossier').having(start=date(2016, 11, 6)))

        binding = Dossier(dossier).binding()
        self.assertEquals(date(2016, 11, 6),
                          binding.eroeffnungsdatum.datum.date())
    def test_id_is_uid_prefixed_with_a_underscore(self):
        self.login(self.regular_user)

        self.assertEquals(u'_createtreatydossiers000000000001',
                          Dossier(self.dossier).binding().id)