Ejemplo n.º 1
0
    def setUp(self):
        super(TestTaskSuggestionBulkEdit, self).setUp()

        acc = models.Account()
        acc.set_id("0987654321")
        acc.set_email("*****@*****.**")
        acc.save()

        egs = EditorGroupFixtureFactory.make_editor_group_source(
            "1234567890", "0987654321")
        egm = models.EditorGroup(**egs)
        egm.save(blocking=True)

        self.suggestions = []
        for app_src in ApplicationFixtureFactory.make_many_application_sources(
                count=TEST_SUGGESTION_COUNT):
            self.suggestions.append(models.Suggestion(**app_src))
            self.suggestions[-1].set_editor_group("1234567890")
            self.suggestions[-1].set_editor("0987654321")
            self.suggestions[-1].save()

        self.default_eg = EditorGroupFixtureFactory.setup_editor_group_with_editors(
        )

        self.forbidden_accounts = [
            AccountFixtureFactory.make_editor_source()['id'],
            AccountFixtureFactory.make_assed1_source()['id'],
            AccountFixtureFactory.make_assed2_source()['id'],
            AccountFixtureFactory.make_assed3_source()['id']
        ]

        self._make_and_push_test_context(acc=models.Account(
            **AccountFixtureFactory.make_managing_editor_source()))
Ejemplo n.º 2
0
    def setUp(self):
        super(TestTaskSuggestionBulkEdit, self).setUp()

        acc = models.Account()
        acc.set_id("0987654321")
        acc.set_email("*****@*****.**")
        acc.save()

        egs = EditorGroupFixtureFactory.make_editor_group_source("1234567890", "0987654321")
        egm = models.EditorGroup(**egs)
        egm.save(blocking=True)

        self.suggestions = []
        for app_src in ApplicationFixtureFactory.make_many_application_sources(count=TEST_SUGGESTION_COUNT):
            self.suggestions.append(models.Suggestion(**app_src))
            self.suggestions[-1].set_editor_group("1234567890")
            self.suggestions[-1].set_editor("0987654321")
            self.suggestions[-1].save()

        self.default_eg = EditorGroupFixtureFactory.setup_editor_group_with_editors()

        self.forbidden_accounts = [
            AccountFixtureFactory.make_editor_source()['id'],
            AccountFixtureFactory.make_assed1_source()['id'],
            AccountFixtureFactory.make_assed2_source()['id'],
            AccountFixtureFactory.make_assed3_source()['id']
        ]

        self._make_and_push_test_context(acc=models.Account(**AccountFixtureFactory.make_managing_editor_source()))
Ejemplo n.º 3
0
    def test_03_workflow_editor_notifications(self):
        ctx = self._make_and_push_test_context()

        emails = {}

        # When we make the application unchanged for a short period of time, we don't tell the editors
        [APPLICATION_SOURCE_1, APPLICATION_SOURCE_2, APPLICATION_SOURCE_3
         ] = ApplicationFixtureFactory.make_many_application_sources(count=3)
        comfortably_idle = app.config['ASSOC_ED_IDLE_DAYS'] + 1
        APPLICATION_SOURCE_1['last_manual_update'] = datetime.utcnow(
        ) - timedelta(days=comfortably_idle)
        application1 = models.Suggestion(**APPLICATION_SOURCE_1)
        application1.save()

        # This exceeds the idle limit, editors should be notified.
        APPLICATION_SOURCE_2['admin'][
            'application_status'] = constants.APPLICATION_STATUS_IN_PROGRESS
        extremely_idle = app.config['ED_IDLE_WEEKS'] + 1
        APPLICATION_SOURCE_2['last_manual_update'] = datetime.utcnow(
        ) - timedelta(weeks=extremely_idle)
        application2 = models.Suggestion(**APPLICATION_SOURCE_2)
        application2.save()

        # This one is assigned to the group but not an associate - editors are reminded.
        extremely_idle = app.config['ED_IDLE_WEEKS'] + 1
        APPLICATION_SOURCE_2['admin'][
            'application_status'] = constants.APPLICATION_STATUS_UPDATE_REQUEST
        APPLICATION_SOURCE_3['last_manual_update'] = datetime.utcnow(
        ) - timedelta(days=extremely_idle)
        APPLICATION_SOURCE_3['admin']['editor'] = None
        application3 = models.Suggestion(**APPLICATION_SOURCE_3)
        application3.save()

        models.Suggestion.blockall([
            (application1.id, application1.last_updated),
            (application2.id, application2.last_updated),
            (application3.id, application3.last_updated)
        ])

        async_workflow_notifications.editor_notifications(emails)

        assert len(emails) > 0
        assert EDITOR_SOURCE['email'] in list(emails.keys())

        email_text_catted = " ".join(emails[EDITOR_SOURCE['email']][1])
        assert '1 application(s) currently assigned to your Editor Group, "editorgroup", which have no Associate Editor' in email_text_catted
        assert "1 application(s) which have been assigned to an Associate Editor but have been idle" in email_text_catted

        ctx.pop()
Ejemplo n.º 4
0
    def test_02_workflow_managing_editor_notifications(self):
        ctx = self._make_and_push_test_context()

        emails = {}

        # When we make the application unchanged for a short period of time, we don't tell the managing editors
        [APPLICATION_SOURCE_1, APPLICATION_SOURCE_2, APPLICATION_SOURCE_3
         ] = ApplicationFixtureFactory.make_many_application_sources(count=3)
        comfortably_idle = app.config['ASSOC_ED_IDLE_DAYS'] + 1
        APPLICATION_SOURCE_1['last_manual_update'] = datetime.utcnow(
        ) - timedelta(days=comfortably_idle)
        application1 = models.Suggestion(**APPLICATION_SOURCE_1)
        application1.save()

        # This exceeds the idle limit, managing editors should be notified.
        APPLICATION_SOURCE_2['admin'][
            'application_status'] = constants.APPLICATION_STATUS_IN_PROGRESS
        extremely_idle = app.config['MAN_ED_IDLE_WEEKS'] + 1
        APPLICATION_SOURCE_2['last_manual_update'] = datetime.utcnow(
        ) - timedelta(weeks=extremely_idle)
        application2 = models.Suggestion(**APPLICATION_SOURCE_2)
        application2.save()

        # This one is ready - managing editors are told as it's now their responsibility.
        APPLICATION_SOURCE_3['last_manual_update'] = datetime.utcnow()
        APPLICATION_SOURCE_3['admin'][
            'application_status'] = constants.APPLICATION_STATUS_READY
        application3 = models.Suggestion(**APPLICATION_SOURCE_3)
        application3.save()

        models.Suggestion.blockall([
            (application1.id, application1.last_updated),
            (application2.id, application2.last_updated),
            (application3.id, application3.last_updated)
        ])

        async_workflow_notifications.managing_editor_notifications(emails)
        assert len(emails) > 0
        assert app.config['MANAGING_EDITOR_EMAIL'] in list(emails.keys())

        email_text_catted = " ".join(
            emails[app.config['MANAGING_EDITOR_EMAIL']][1])
        assert '1 application(s) are assigned to an Associate Editor' in email_text_catted
        assert "There are 1 records in status 'Ready'" in email_text_catted
        ctx.pop()
Ejemplo n.º 5
0
    def test_03_workflow_editor_notifications(self):
        ctx = self._make_and_push_test_context()

        emails = {}

        # When we make the application unchanged for a short period of time, we don't tell the editors
        [APPLICATION_SOURCE_1, APPLICATION_SOURCE_2, APPLICATION_SOURCE_3] = ApplicationFixtureFactory.make_many_application_sources(count=3)
        comfortably_idle = app.config['ASSOC_ED_IDLE_DAYS'] + 1
        APPLICATION_SOURCE_1['last_manual_update'] = datetime.utcnow() - timedelta(days=comfortably_idle)
        application1 = models.Suggestion(**APPLICATION_SOURCE_1)
        application1.save()

        # This exceeds the idle limit, editors should be notified.
        APPLICATION_SOURCE_2['admin']['application_status'] = constants.APPLICATION_STATUS_IN_PROGRESS
        extremely_idle = app.config['ED_IDLE_WEEKS'] + 1
        APPLICATION_SOURCE_2['last_manual_update'] = datetime.utcnow() - timedelta(weeks=extremely_idle)
        application2 = models.Suggestion(**APPLICATION_SOURCE_2)
        application2.save()

        # This one is assigned to the group but not an associate - editors are reminded.
        extremely_idle = app.config['ED_IDLE_WEEKS'] + 1
        APPLICATION_SOURCE_2['admin']['application_status'] = constants.APPLICATION_STATUS_UPDATE_REQUEST
        APPLICATION_SOURCE_3['last_manual_update'] = datetime.utcnow() - timedelta(days=extremely_idle)
        APPLICATION_SOURCE_3['admin']['editor'] = None
        application3 = models.Suggestion(**APPLICATION_SOURCE_3)
        application3.save()

        models.Suggestion.blockall([
            (application1.id, application1.last_updated),
            (application2.id, application2.last_updated),
            (application3.id, application3.last_updated)
        ])

        async_workflow_notifications.editor_notifications(emails)

        assert len(emails) > 0
        assert EDITOR_SOURCE['email'] in emails.keys()

        email_text_catted = " ".join(emails[EDITOR_SOURCE['email']][1])
        assert u'1 application(s) currently assigned to your Editor Group, "editorgroup", which have no Associate Editor' in email_text_catted
        assert u"1 application(s) which have been assigned to an Associate Editor but have been idle" in email_text_catted

        ctx.pop()
Ejemplo n.º 6
0
    def test_04_workflow_associate_editor_notifications(self):
        ctx = self._make_and_push_test_context()

        APPLICATION_SOURCE['last_manual_update'] = datetime.utcnow()
        application = models.Suggestion(**APPLICATION_SOURCE)
        application.save(blocking=True)

        # This application is assigned to associate editor 1, but it is not yet stale enough to require a reminder
        emails = {}
        async_workflow_notifications.associate_editor_notifications(emails)
        assert_false(emails)

        # When we make the application unchanged for a period of time, we expect a message to be generated
        [APPLICATION_SOURCE_2, APPLICATION_SOURCE_3
         ] = ApplicationFixtureFactory.make_many_application_sources(count=2)
        comfortably_idle = app.config['ASSOC_ED_IDLE_DAYS'] + 1
        APPLICATION_SOURCE_2['last_manual_update'] = datetime.utcnow(
        ) - timedelta(days=comfortably_idle)
        application2 = models.Suggestion(**APPLICATION_SOURCE_2)
        application2.save()

        extremely_idle = app.config['ASSOC_ED_IDLE_WEEKS'] + 1
        APPLICATION_SOURCE_3['last_manual_update'] = datetime.utcnow(
        ) - timedelta(weeks=extremely_idle)
        application3 = models.Suggestion(**APPLICATION_SOURCE_3)
        application3.save()

        models.Suggestion.blockall([
            (application.id, application.last_updated),
            (application2.id, application2.last_updated),
            (application3.id, application3.last_updated)
        ])

        async_workflow_notifications.associate_editor_notifications(emails)
        assert len(emails) > 0
        assert ASSED1_SOURCE['email'] in list(emails.keys())

        email_text = emails[ASSED1_SOURCE['email']][1].pop()
        assert 'You have 2 application(s) assigned to you' in email_text
        assert 'including 1 which have been unchanged' in email_text

        ctx.pop()
Ejemplo n.º 7
0
    def test_02_workflow_managing_editor_notifications(self):
        ctx = self._make_and_push_test_context()

        emails = {}

        # When we make the application unchanged for a short period of time, we don't tell the managing editors
        [APPLICATION_SOURCE_1, APPLICATION_SOURCE_2, APPLICATION_SOURCE_3] = ApplicationFixtureFactory.make_many_application_sources(count=3)
        comfortably_idle = app.config['ASSOC_ED_IDLE_DAYS'] + 1
        APPLICATION_SOURCE_1['last_manual_update'] = datetime.utcnow() - timedelta(days=comfortably_idle)
        application1 = models.Suggestion(**APPLICATION_SOURCE_1)
        application1.save()

        # This exceeds the idle limit, managing editors should be notified.
        APPLICATION_SOURCE_2['admin']['application_status'] = constants.APPLICATION_STATUS_IN_PROGRESS
        extremely_idle = app.config['MAN_ED_IDLE_WEEKS'] + 1
        APPLICATION_SOURCE_2['last_manual_update'] = datetime.utcnow() - timedelta(weeks=extremely_idle)
        application2 = models.Suggestion(**APPLICATION_SOURCE_2)
        application2.save()

        # This one is ready - managing editors are told as it's now their responsibility.
        APPLICATION_SOURCE_3['last_manual_update'] = datetime.utcnow()
        APPLICATION_SOURCE_3['admin']['application_status'] = constants.APPLICATION_STATUS_READY
        application3 = models.Suggestion(**APPLICATION_SOURCE_3)
        application3.save()

        models.Suggestion.blockall([
            (application1.id, application1.last_updated),
            (application2.id, application2.last_updated),
            (application3.id, application3.last_updated)
        ])

        async_workflow_notifications.managing_editor_notifications(emails)
        assert len(emails) > 0
        assert app.config['MANAGING_EDITOR_EMAIL'] in emails.keys()

        email_text_catted = " ".join(emails[app.config['MANAGING_EDITOR_EMAIL']][1])
        assert u'1 application(s) are assigned to an Associate Editor' in email_text_catted
        assert u"There are 1 records in status 'Ready'" in email_text_catted
        ctx.pop()
Ejemplo n.º 8
0
    def test_04_workflow_associate_editor_notifications(self):
        ctx = self._make_and_push_test_context()

        APPLICATION_SOURCE['last_manual_update'] = datetime.utcnow()
        application = models.Suggestion(**APPLICATION_SOURCE)
        application.save(blocking=True)

        # This application is assigned to associate editor 1, but it is not yet stale enough to require a reminder
        emails = {}
        async_workflow_notifications.associate_editor_notifications(emails)
        assert_false(emails)

        # When we make the application unchanged for a period of time, we expect a message to be generated
        [APPLICATION_SOURCE_2, APPLICATION_SOURCE_3] = ApplicationFixtureFactory.make_many_application_sources(count=2)
        comfortably_idle = app.config['ASSOC_ED_IDLE_DAYS'] + 1
        APPLICATION_SOURCE_2['last_manual_update'] = datetime.utcnow() - timedelta(days=comfortably_idle)
        application2 = models.Suggestion(**APPLICATION_SOURCE_2)
        application2.save()

        extremely_idle = app.config['ASSOC_ED_IDLE_WEEKS'] + 1
        APPLICATION_SOURCE_3['last_manual_update'] = datetime.utcnow() - timedelta(weeks=extremely_idle)
        application3 = models.Suggestion(**APPLICATION_SOURCE_3)
        application3.save()

        models.Suggestion.blockall([
            (application.id, application.last_updated),
            (application2.id, application2.last_updated),
            (application3.id, application3.last_updated)
        ])

        async_workflow_notifications.associate_editor_notifications(emails)
        assert len(emails) > 0
        assert ASSED1_SOURCE['email'] in emails.keys()

        email_text = emails[ASSED1_SOURCE['email']][1].pop()
        assert u'You have 2 application(s) assigned to you' in email_text
        assert u'including 1 which have been unchanged' in email_text

        ctx.pop()