示例#1
0
    def test_review_locked_questionnaire_blocked_by_other(self):

        # Reviewer logs in and goes to the details of a SUBMITTED questionnaire
        detail_page = SampleDetailPage(self)
        detail_page.route_kwargs = {'identifier': 'sample_2'}
        detail_page.open(login=True, user=self.user_reviewer)
        assert detail_page.has_text('Foo 2')

        # He starts to edit the first section (this sets a lock on the
        # questionnaire)
        detail_page.edit_questionnaire()
        edit_page = SampleEditPage(self)
        edit_page.click_edit_category('cat_1')

        # Secretariat user logs in and goes to the details of the same
        # questionnaire
        detail_page.open(login=True, user=self.user_secretariat)
        assert detail_page.has_text('Foo 2')

        # The user sees a message that the questionnaire is currently locked
        assert detail_page.is_locked_by(user=self.user_reviewer)

        # He reviews the questionnaire which is still locked and sees there is
        # no exception thrown, however she sees a warning.
        detail_page.review_questionnaire(check_success=False)
        assert detail_page.is_locked_by(user=self.user_reviewer)

        # He sees the questionnaire is still submitted
        detail_page.check_status('submitted')
示例#2
0
    def test_review_locked_questionnaire(self):
        # Secretariat user logs in and goes to the details of a SUBMITTED
        # questionnaire
        detail_page = SampleDetailPage(self)
        detail_page.route_kwargs = {'identifier': 'sample_2'}
        detail_page.open(login=True, user=self.user_secretariat)
        assert detail_page.has_text(self.sample_2_text)

        # User starts to edit the first section (this sets a lock on the
        # questionnaire)
        detail_page.edit_questionnaire()
        edit_page = SampleEditPage(self)
        edit_page.click_edit_category(edit_page.CATEGORIES[0][0])

        # User goes back to the details (without saving!)
        detail_page.open()

        # User reviews the questionnaire and sees there is no exception thrown
        detail_page.review_questionnaire()

        # He sees the questionnaire is now reviewed
        detail_page.check_status('reviewed')
示例#3
0
    def test_secretariat_delete(self):
        # Secretariat user logs in
        # He goes to the details of a DRAFT questionnaire which he did not enter
        detail_page = SampleDetailPage(self)
        detail_page.route_kwargs = {'identifier': 'sample_1'}
        detail_page.open(login=True, user=self.user_secretariat)
        assert detail_page.has_text('Foo 1')
        detail_page.check_status('draft')

        # He deletes the questionnaire.
        detail_page.delete_questionnaire()

        # He sees that he has been redirected to the "My SLM Practices" page
        my_data_page = MyDataPage(self)
        assert my_data_page.get_url() in self.browser.current_url

        # He goes to the details of a SUBMITTED questionnaire which he did not
        # enter
        detail_page.route_kwargs = {'identifier': 'sample_2'}
        detail_page.open()
        assert detail_page.has_text('Foo 2')
        detail_page.check_status('submitted')

        # He deletes the questionnaire.
        detail_page.delete_questionnaire()

        # He sees that he has been redirected to the "My SLM Practices" page
        assert my_data_page.get_url() in self.browser.current_url

        # He goes to the details of a REVIEWED questionnaire which he did not
        # enter
        detail_page.route_kwargs = {'identifier': 'sample_7'}
        detail_page.open()
        assert detail_page.has_text('Foo 7')
        detail_page.check_status('reviewed')

        # He deletes the questionnaire.
        detail_page.delete_questionnaire()

        # He sees that he has been redirected to the "My SLM Practices" page
        assert my_data_page.get_url() in self.browser.current_url

        # He also opens a PUBLIC questionnaire which he did not enter
        detail_page.route_kwargs = {'identifier': 'sample_3'}
        detail_page.open()
        assert detail_page.has_text('Foo 3')

        # In the database, there is only 1 version
        query_sample_3 = Questionnaire.objects.get(code='sample_3')
        assert query_sample_3.status == settings.QUESTIONNAIRE_PUBLIC
        assert not query_sample_3.is_deleted

        # He deletes the questionnaire.
        detail_page.delete_questionnaire()

        # He sees that he has been redirected to the "My SLM Practices" page
        assert my_data_page.get_url() in self.browser.current_url

        # In the database, there is still only 1 version
        query_sample_3 = Questionnaire.objects.get(code='sample_3')
        assert query_sample_3.status == settings.QUESTIONNAIRE_PUBLIC
        assert query_sample_3.is_deleted

        # He opens another PUBLIC questionnaire and edits it
        detail_page.route_kwargs = {'identifier': 'sample_5'}
        detail_page.open()
        assert detail_page.has_text('Foo 5')

        detail_page.create_new_version()

        # He deletes the newly created draft version
        detail_page.check_status('draft')
        detail_page.delete_questionnaire()

        # He sees that he has been redirected to the PUBLIC version of the
        # questionnaire, not the "My SLM Practices" page
        assert detail_page.get_url() in self.browser.current_url

        # He creates another version by editing it
        detail_page.create_new_version()

        # This time, he publishes the new version
        detail_page.submit_questionnaire()
        detail_page.review_questionnaire()
        detail_page.publish_questionnaire()

        # Now he deletes it
        detail_page.delete_questionnaire()

        # He is now redirected to the "My SLM Practices" page as there is no
        # version to show
        assert my_data_page.get_url() in self.browser.current_url