예제 #1
0
 def test__convert_front_page_converted(self):
     """Test converting front page from Collection to Document"""
     from osha.policy.upgrades import _convert_front_page
     new_front_page = _convert_front_page(
         obj=self.director_corner_en['blog']['front-page'],
         wf_state='private',
         layout='blog-view')
     self.assertEquals(new_front_page.portal_type, 'Document')
     self.assertEquals(new_front_page.getLayout(), 'blog-view')
예제 #2
0
 def test__convert_front_page_converted(self):
     """Test converting front page from Collection to Document"""
     from osha.policy.upgrades import _convert_front_page
     new_front_page = _convert_front_page(
         obj=self.director_corner_en['blog']['front-page'],
         wf_state='private',
         layout='blog-view'
     )
     self.assertEquals(new_front_page.portal_type, 'Document')
     self.assertEquals(new_front_page.getLayout(), 'blog-view')
예제 #3
0
    def test__convert_front_page_state_not_published(self):
        """Test if the right workflow state is set for the front page if
        wf_state is not 'published'.
        """
        from osha.policy.upgrades import _convert_front_page
        new_front_page = _convert_front_page(
            obj=self.director_corner_en['blog']['front-page'],
            wf_state='visible',
            layout='blog-view')

        self.assertEquals(api.content.get_state(obj=new_front_page), 'private')
예제 #4
0
    def test__convert_front_page_state_published(self):
        """Test if the right workflow state is set for the front page if
        wf_state is set to 'published'.
        """
        from osha.policy.upgrades import _convert_front_page
        new_front_page = _convert_front_page(
            obj=self.director_corner_en['blog']['front-page'],
            wf_state='published',
            layout='blog-view'
        )

        self.assertEquals(
            api.content.get_state(obj=new_front_page), 'published')
예제 #5
0
    def test__convert_front_page_fix_text_no_oshblog(self):
        """Test if the body text is set correctly if no 'OSH blog' text is
        present in the front-page body.
        """
        from osha.policy.upgrades import _convert_front_page
        self.director_corner_en['front-page'].setText('foo')
        new_front_page = _convert_front_page(
            obj=self.director_corner_en['front-page'],
            wf_state='published',
            layout='director-corner-view',
            fix_text=True)

        # body text shouldn't be altered
        self.assertEquals(new_front_page.getText(), """<p>foo</p>""")
예제 #6
0
    def test__convert_front_page_fix_text_disabled(self):
        """Test if the body text is untouched if fix_test is set to False.
        """
        from osha.policy.upgrades import _convert_front_page
        new_front_page = _convert_front_page(
            obj=self.director_corner_en['front-page'],
            wf_state='published',
            layout='director-corner-view',
            fix_text=False)

        # body text shouldn't be altered
        self.assertEquals(
            new_front_page.getText(),
            """<p>\r\n\t<img align="left" alt="Picture of Dr Christa Sedlatschek" height="91" src="/en/teaser/Dr-Christa-Sedlatschek-appointed-to-lead-EU-OSHA/image" width="80" /></p>\r\n<h2>\r\n\t&nbsp;Short profile of Dr Christa Sedlatschek</h2>\r\n<p>\r\n\t&nbsp;<strong>Dr Christa Sedlatschek</strong>&nbsp;is a medical doctor (University of Vienna) and a specialist in occupational health.</p>\r\n<p>\r\n\t&nbsp;After completing her studies she started working in the Austrian labour inspectorate and moved to the Ministry for Labour and Social Affairs in 1993, taking over the function as Deputy Head of the department for occupational medicine.</p>\r\n<p>\r\n\tIn 1998 she was recruited by EU-OSHA where she focused on the development and dissemination of good practice information, becoming the head of the working environment unit. During that time she gained an in-depth knowledge about the EU and existing occupational safety and health (OSH) systems in the Member States.</p>\r\n<p>\r\n\tIn 2003 she moved to Berlin and started working in the Federal Institute for Occupational Safety and Health (Bundesanstalt f\xc3\xbcr Arbeitsschutz und Arbeitsmedizin - BAuA), where she became Director of the national \xe2\x80\x9cInitiative New Quality of Work - INQA\xe2\x80\x9d in 2004.</p>\r\n<p>\r\n\t\xe2\x80\x9cINQA\xe2\x80\x9d was launched by the German Federal Ministry for labour and social affairs as a consequence of the Lisbon Summit in 2000, aiming at making a contribution towards creating more and better jobs in Europe.</p>\r\n<p>\r\n\t&nbsp;</p>\r\n<h2>\r\n\tOSH Blog</h2>\r\n<p class="documentDescription" style="border: 1px dotted rgb(197, 203, 216); margin-bottom: 2em; margin-right: 15px; padding-bottom: 5px; padding-left: 3px;">\r\n\t<img alt="blog_logo-def.jpg" height="80" src="/en/blog/blogo_logo" style="float: right;" width="80" />The aim of this blog is to bring you news about developments in occupational safety and health across the EU and beyond, and also about EU-OSHA initiatives and activities to fulfill our mission.<br />\r\n\tWe are one of the smallest EU agencies and cannot promise to reply to every comment, but we will read them and bear them in mind to shape our future work.<br />\r\n\t&nbsp;</p>\r\n"""
        )
예제 #7
0
    def test__convert_front_page_fix_text_oshblog(self):
        """Test if the body text is set correctly if 'OSH blog' text is
        present in the front-page body.
        """
        from osha.policy.upgrades import _convert_front_page
        new_front_page = _convert_front_page(
            obj=self.director_corner_en['front-page'],
            wf_state='published',
            layout='director-corner-view',
            fix_text=True)

        # OSH Blog description should be removed from the body text
        self.assertEquals(
            new_front_page.getText(),
            """<p>\r\n\t<img align="left" alt="Picture of Dr Christa Sedlatschek" height="91" src="/en/teaser/Dr-Christa-Sedlatschek-appointed-to-lead-EU-OSHA/image" width="80" /></p>\r\n<h2>\r\n\t&nbsp;Short profile of Dr Christa Sedlatschek</h2>\r\n<p>\r\n\t&nbsp;<strong>Dr Christa Sedlatschek</strong>&nbsp;is a medical doctor (University of Vienna) and a specialist in occupational health.</p>\r\n<p>\r\n\t&nbsp;After completing her studies she started working in the Austrian labour inspectorate and moved to the Ministry for Labour and Social Affairs in 1993, taking over the function as Deputy Head of the department for occupational medicine.</p>\r\n<p>\r\n\tIn 1998 she was recruited by EU-OSHA where she focused on the development and dissemination of good practice information, becoming the head of the working environment unit. During that time she gained an in-depth knowledge about the EU and existing occupational safety and health (OSH) systems in the Member States.</p>\r\n<p>\r\n\tIn 2003 she moved to Berlin and started working in the Federal Institute for Occupational Safety and Health (Bundesanstalt f\xc3\xbcr Arbeitsschutz und Arbeitsmedizin - BAuA), where she became Director of the national \xe2\x80\x9cInitiative New Quality of Work - INQA\xe2\x80\x9d in 2004.</p>\r\n<p>\r\n\t\xe2\x80\x9cINQA\xe2\x80\x9d was launched by the German Federal Ministry for labour and social affairs as a consequence of the Lisbon Summit in 2000, aiming at making a contribution towards creating more and better jobs in Europe.</p>\r\n<p>\r\n\t&nbsp;</p>\r\n"""
        )
예제 #8
0
    def test__convert_front_page_fix_text_disabled(self):
        """Test if the body text is untouched if fix_test is set to False.
        """
        from osha.policy.upgrades import _convert_front_page
        new_front_page = _convert_front_page(
            obj=self.director_corner_en['front-page'],
            wf_state='published',
            layout='director-corner-view',
            fix_text=False
        )

        # body text shouldn't be altered
        self.assertEquals(
            new_front_page.getText(),
            """<p>\r\n\t<img align="left" alt="Picture of Dr Christa Sedlatschek" height="91" src="/en/teaser/Dr-Christa-Sedlatschek-appointed-to-lead-EU-OSHA/image" width="80" /></p>\r\n<h2>\r\n\t&nbsp;Short profile of Dr Christa Sedlatschek</h2>\r\n<p>\r\n\t&nbsp;<strong>Dr Christa Sedlatschek</strong>&nbsp;is a medical doctor (University of Vienna) and a specialist in occupational health.</p>\r\n<p>\r\n\t&nbsp;After completing her studies she started working in the Austrian labour inspectorate and moved to the Ministry for Labour and Social Affairs in 1993, taking over the function as Deputy Head of the department for occupational medicine.</p>\r\n<p>\r\n\tIn 1998 she was recruited by EU-OSHA where she focused on the development and dissemination of good practice information, becoming the head of the working environment unit. During that time she gained an in-depth knowledge about the EU and existing occupational safety and health (OSH) systems in the Member States.</p>\r\n<p>\r\n\tIn 2003 she moved to Berlin and started working in the Federal Institute for Occupational Safety and Health (Bundesanstalt f\xc3\xbcr Arbeitsschutz und Arbeitsmedizin - BAuA), where she became Director of the national \xe2\x80\x9cInitiative New Quality of Work - INQA\xe2\x80\x9d in 2004.</p>\r\n<p>\r\n\t\xe2\x80\x9cINQA\xe2\x80\x9d was launched by the German Federal Ministry for labour and social affairs as a consequence of the Lisbon Summit in 2000, aiming at making a contribution towards creating more and better jobs in Europe.</p>\r\n<p>\r\n\t&nbsp;</p>\r\n<h2>\r\n\tOSH Blog</h2>\r\n<p class="documentDescription" style="border: 1px dotted rgb(197, 203, 216); margin-bottom: 2em; margin-right: 15px; padding-bottom: 5px; padding-left: 3px;">\r\n\t<img alt="blog_logo-def.jpg" height="80" src="/en/blog/blogo_logo" style="float: right;" width="80" />The aim of this blog is to bring you news about developments in occupational safety and health across the EU and beyond, and also about EU-OSHA initiatives and activities to fulfill our mission.<br />\r\n\tWe are one of the smallest EU agencies and cannot promise to reply to every comment, but we will read them and bear them in mind to shape our future work.<br />\r\n\t&nbsp;</p>\r\n"""
        )
예제 #9
0
    def test__convert_front_page_fix_text_oshblog(self):
        """Test if the body text is set correctly if 'OSH blog' text is
        present in the front-page body.
        """
        from osha.policy.upgrades import _convert_front_page
        new_front_page = _convert_front_page(
            obj=self.director_corner_en['front-page'],
            wf_state='published',
            layout='director-corner-view',
            fix_text=True
        )

        # OSH Blog description should be removed from the body text
        self.assertEquals(
            new_front_page.getText(),
            """<p>\r\n\t<img align="left" alt="Picture of Dr Christa Sedlatschek" height="91" src="/en/teaser/Dr-Christa-Sedlatschek-appointed-to-lead-EU-OSHA/image" width="80" /></p>\r\n<h2>\r\n\t&nbsp;Short profile of Dr Christa Sedlatschek</h2>\r\n<p>\r\n\t&nbsp;<strong>Dr Christa Sedlatschek</strong>&nbsp;is a medical doctor (University of Vienna) and a specialist in occupational health.</p>\r\n<p>\r\n\t&nbsp;After completing her studies she started working in the Austrian labour inspectorate and moved to the Ministry for Labour and Social Affairs in 1993, taking over the function as Deputy Head of the department for occupational medicine.</p>\r\n<p>\r\n\tIn 1998 she was recruited by EU-OSHA where she focused on the development and dissemination of good practice information, becoming the head of the working environment unit. During that time she gained an in-depth knowledge about the EU and existing occupational safety and health (OSH) systems in the Member States.</p>\r\n<p>\r\n\tIn 2003 she moved to Berlin and started working in the Federal Institute for Occupational Safety and Health (Bundesanstalt f\xc3\xbcr Arbeitsschutz und Arbeitsmedizin - BAuA), where she became Director of the national \xe2\x80\x9cInitiative New Quality of Work - INQA\xe2\x80\x9d in 2004.</p>\r\n<p>\r\n\t\xe2\x80\x9cINQA\xe2\x80\x9d was launched by the German Federal Ministry for labour and social affairs as a consequence of the Lisbon Summit in 2000, aiming at making a contribution towards creating more and better jobs in Europe.</p>\r\n<p>\r\n\t&nbsp;</p>\r\n"""
        )
예제 #10
0
    def test__convert_front_page_fix_text_no_oshblog(self):
        """Test if the body text is set correctly if no 'OSH blog' text is
        present in the front-page body.
        """
        from osha.policy.upgrades import _convert_front_page
        self.director_corner_en['front-page'].setText('foo')
        new_front_page = _convert_front_page(
            obj=self.director_corner_en['front-page'],
            wf_state='published',
            layout='director-corner-view',
            fix_text=True
        )

        # body text shouldn't be altered
        self.assertEquals(
            new_front_page.getText(),
            """<p>foo</p>"""
        )
예제 #11
0
    def _test__convert_front_page_non_addable(self):
        """Test if correctly handle the case when Documents are not addable
        to the blog subfolder.
        """
        from osha.policy.upgrades import _convert_front_page

        # set 'Collection' as the only addable type
        blog = self.director_corner_en['blog']
        blog.setLocallyAllowedTypes(('Collection', ))
        new_front_page = _convert_front_page(
            obj=self.director_corner_en['blog']['front-page'],
            wf_state='published',
            layout='blog-view')

        # we shouldn't get an error, 'Document' should be added to the list
        # of available types
        self.assertIn('front-page', blog.keys())
        self.assertEquals(new_front_page.portal_type, 'Document')
        self.assertEquals(blog.getLocallyAllowedTypes(), (
            'Collection',
            'Document',
        ))
예제 #12
0
    def _test__convert_front_page_non_addable(self):
        """Test if correctly handle the case when Documents are not addable
        to the blog subfolder.
        """
        from osha.policy.upgrades import _convert_front_page

        # set 'Collection' as the only addable type
        blog = self.director_corner_en['blog']
        blog.setLocallyAllowedTypes(('Collection', ))
        new_front_page = _convert_front_page(
            obj=self.director_corner_en['blog']['front-page'],
            wf_state='published',
            layout='blog-view'
        )

        # we shouldn't get an error, 'Document' should be added to the list
        # of available types
        self.assertIn('front-page', blog.keys())
        self.assertEquals(new_front_page.portal_type, 'Document')
        self.assertEquals(
            blog.getLocallyAllowedTypes(),
            ('Collection', 'Document',)
        )