Exemple #1
0
def create_edit_cases():
    application_source = ApplicationFixtureFactory.make_application_source()
    account_source = AccountFixtureFactory.make_publisher_source()

    editable_application = Suggestion(**application_source)
    editable_application.set_application_status(constants.APPLICATION_STATUS_UPDATE_REQUEST)

    non_editable_application = Suggestion(**application_source)
    non_editable_application.set_application_status(constants.APPLICATION_STATUS_READY)

    owner_account = Account(**deepcopy(account_source))
    owner_account.set_id(editable_application.owner)

    non_owner_publisher = Account(**deepcopy(account_source))

    non_publisher = Account(**deepcopy(account_source))
    non_publisher.remove_role("publisher")

    admin = Account(**deepcopy(account_source))
    admin.add_role("admin")

    return [
        param("no_app_no_account", None, None, raises=exceptions.ArgumentException),
        param("no_app_with_account", None, owner_account, raises=exceptions.ArgumentException),
        param("app_no_account", editable_application, None, raises=exceptions.ArgumentException),
        param("editable_app_owning_account", editable_application, owner_account, expected=True),
        param("editable_app_nonowning_account", editable_application, non_owner_publisher, raises=exceptions.AuthoriseException),
        param("editable_app_non_publisher_account", editable_application, non_publisher, raises=exceptions.AuthoriseException),
        param("editable_app_admin_account", editable_application, admin, expected=True),
        param("non_editable_app_owning_account", non_editable_application, owner_account, raises=exceptions.AuthoriseException),
        param("non_editable_app_nonowning_account", non_editable_application, non_owner_publisher, raises=exceptions.AuthoriseException),
        param("non_editable_app_non_publisher_account", non_editable_application, non_publisher, raises=exceptions.AuthoriseException),
        param("non_editable_app_admin_account", non_editable_application, admin, expected=True)
    ]
def load_j2a_cases():
    journal = Journal(**JournalFixtureFactory.make_journal_source(
        in_doaj=True))
    account_source = AccountFixtureFactory.make_publisher_source()

    owner_account = Account(**deepcopy(account_source))
    owner_account.set_id(journal.owner)

    non_owner_publisher = Account(**deepcopy(account_source))

    non_publisher = Account(**deepcopy(account_source))
    non_publisher.remove_role("publisher")

    admin = Account(**deepcopy(account_source))
    admin.add_role("admin")

    return [
        param("no_journal_no_account",
              None,
              None,
              raises=exceptions.ArgumentException),
        param("no_journal_with_account",
              None,
              owner_account,
              raises=exceptions.ArgumentException),
        param("journal_no_account",
              journal,
              None,
              comparator=application_matches),
        param("journal_matching_account",
              journal,
              owner_account,
              comparator=application_matches),
        param("journal_unmatched_account",
              journal,
              non_owner_publisher,
              raises=exceptions.AuthoriseException),
        param("journal_non_publisher_account",
              journal,
              non_publisher,
              raises=exceptions.AuthoriseException),
        param("journal_admin_account",
              journal,
              admin,
              comparator=application_matches)
    ]
def load_j2a_cases():
    journal = Journal(**JournalFixtureFactory.make_journal_source(in_doaj=True))
    account_source = AccountFixtureFactory.make_publisher_source()

    owner_account = Account(**deepcopy(account_source))
    owner_account.set_id(journal.owner)

    non_owner_publisher = Account(**deepcopy(account_source))

    non_publisher = Account(**deepcopy(account_source))
    non_publisher.remove_role("publisher")

    admin = Account(**deepcopy(account_source))
    admin.add_role("admin")

    return [
        param("no_journal_no_account", None, None, raises=exceptions.ArgumentException),
        param("no_journal_with_account", None, owner_account, raises=exceptions.ArgumentException),
        param("journal_no_account", journal, None, comparator=application_matches),
        param("journal_matching_account", journal, owner_account, comparator=application_matches),
        param("journal_unmatched_account", journal, non_owner_publisher, raises=exceptions.AuthoriseException),
        param("journal_non_publisher_account", journal, non_publisher, raises=exceptions.AuthoriseException),
        param("journal_admin_account", journal, admin, comparator=application_matches)
    ]
Exemple #4
0
class TestCreateOrUpdateArticle(DoajTestCase):
    def setUp(self):
        super(TestCreateOrUpdateArticle, self).setUp()

        self.publisher = Account()
        self.publisher.add_role("publisher")
        self.publisher.save(blocking=True)

        self.admin = Account()
        self.admin.add_role("admin")
        self.admin.save(blocking=True)

        sources = JournalFixtureFactory.make_many_journal_sources(2, True)
        self.journal1 = Journal(**sources[0])
        self.journal1.set_owner(self.publisher.id)
        jbib1 = self.journal1.bibjson()
        jbib1.add_identifier(jbib1.P_ISSN, "1111-1111")
        jbib1.add_identifier(jbib1.E_ISSN, "2222-2222")
        self.journal1.save(blocking=True)

        self.publisher.add_journal(self.journal1)

        self.journal2 = Journal(**sources[1])
        jbib2 = self.journal2.bibjson()
        jbib2.add_identifier(jbib2.P_ISSN, "1234-5678")
        jbib2.add_identifier(jbib2.E_ISSN, "9876-5432")
        self.journal2.save(blocking=True)

        self.article10 = Article(**ArticleFixtureFactory.make_article_source(
            pissn="1111-1111",
            eissn="2222-2222",
            doi="10.0000/article-10",
            fulltext="https://www.article10.com"))
        self.article10.set_id("articleid10")
        self.article10.save(blocking=True)

        self.article11 = Article(**ArticleFixtureFactory.make_article_source(
            pissn="1111-1111",
            eissn="2222-2222",
            doi="10.0000/article-11",
            fulltext="https://www.article11.com"))
        self.article11.set_id("articleid11")
        self.article11.save(blocking=True)

        self.article2 = Article(**ArticleFixtureFactory.make_article_source(
            pissn="1234-5678",
            eissn="9876-5432",
            doi="10.0000/article-2",
            fulltext="https://www.article2.com"))
        self.article2.set_id("articleid2")
        self.article2.save(blocking=True)

    def tearDown(self):
        super(TestCreateOrUpdateArticle, self).tearDown()

    def test_00_no_doi_and_url_changed(self):
        ba = self.article10.bibjson()
        ba.title = "Updated Article"

        # try for admin

        resp = ArticleService.create_article(
            self=ArticleService(),
            account=self.admin,
            article=self.article10,
            update_article_id=self.article10.id)

        assert resp["success"] == 1, "expected 1 updated, received: {}".format(
            resp)
        assert resp["update"] == 1, "expected 1 updated, received: {}".format(
            resp)
        assert resp["new"] == 0, "expected 1 updated, received: {}".format(
            resp)
        assert self.article10.bibjson().title == "Updated Article", "Expected `Updated Article`, received: {}" \
            .format(self.article10.bibjson().title)

        ba.title = "Updated 2nd time"

        # try for publisher

        resp = ArticleService.create_article(self=ArticleService(),
                                             account=self.publisher,
                                             article=self.article10)

        assert resp["success"] == 1, "expected 1 updated, received: {}".format(
            resp)
        assert resp["update"] == 1, "expected 1 updated, received: {}".format(
            resp)
        assert resp["new"] == 0, "expected 1 updated, received: {}".format(
            resp)
        assert self.article10.bibjson().title == "Updated 2nd time", "Expected `Updated 2nd time`, received: {}" \
            .format(self.article10.bibjson().title)

    def test_01_new_doi_new_url(self):
        ba = self.article10.bibjson()
        ba.remove_identifiers(ba.DOI)
        ba.remove_urls(ba.FULLTEXT)
        ba.add_identifier(ba.DOI, "10.0000/NEW")
        ba.add_url(ba.FULLTEXT, "https://www.UPDATED.com")

        #for publisher
        resp = ArticleService.create_article(self=ArticleService(),
                                             account=self.publisher,
                                             article=self.article10)
        assert resp["success"] == 1, "expected 1 new, received: {}".format(
            resp)
        assert resp["update"] == 0, "expected 1 new, received: {}".format(resp)
        assert resp["new"] == 1, "expected 1 new, received: {}".format(resp)

        #for admin
        resp = ArticleService.create_article(
            self=ArticleService(),
            account=self.admin,
            article=self.article10,
            update_article_id=self.article10.id)

        assert resp["success"] == 1, "expected 1 new, received: {}".format(
            resp)
        assert resp["update"] == 1, "expected 1 new, received: {}".format(resp)
        assert resp["new"] == 0, "expected 1 new, received: {}".format(resp)

    def test_02_old_doi_existing_url_admin(self):
        ba = self.article10.bibjson()
        ba.remove_urls(ba.FULLTEXT)
        # check for url from other article owned by the same publisher
        ba.add_url(self.article11.bibjson().get_single_url(ba.FULLTEXT),
                   ba.FULLTEXT)

        # try as a publisher
        with self.assertRaises(ArticleMergeConflict):
            ArticleService.create_article(self=ArticleService(),
                                          account=self.publisher,
                                          article=self.article10)

        # try as an admin
        with self.assertRaises(ArticleMergeConflict):
            ArticleService.create_article(self=ArticleService(),
                                          account=self.admin,
                                          article=self.article10,
                                          update_article_id=self.article10.id)

        # check for url from other article owned by someone else
        ba.remove_urls(ba.FULLTEXT)
        ba.add_url(self.article2.bibjson().get_single_url(ba.FULLTEXT),
                   ba.FULLTEXT)

        # try as a publisher
        with self.assertRaises(ArticleMergeConflict):
            ArticleService.create_article(self=ArticleService(),
                                          account=self.publisher,
                                          article=self.article10)

        # try as an admin
        with self.assertRaises(ArticleMergeConflict):
            ArticleService.create_article(self=ArticleService(),
                                          account=self.admin,
                                          article=self.article10,
                                          update_article_id=self.article10.id)

    def test_03_existing_doi_old_url_admin(self):
        ba = self.article10.bibjson()
        ba.remove_identifiers(ba.DOI)
        # check for DOI from other article owned by the same publisher
        ba.add_identifier(ba.DOI, "10.0000/article-11")

        # try as a publisher
        with self.assertRaises(ArticleMergeConflict):
            ArticleService.create_article(self=ArticleService(),
                                          account=self.publisher,
                                          article=self.article10)

        # try as an admin
        with self.assertRaises(ArticleMergeConflict):
            ArticleService.create_article(self=ArticleService(),
                                          account=self.admin,
                                          article=self.article10,
                                          update_article_id=self.article10.id)

        ba.remove_identifiers(ba.DOI)
        # check for DOI from other article owned by someone else
        ba.add_identifier(ba.DOI, "10.0000/article-2")

        # try as a publisher
        with self.assertRaises(ArticleMergeConflict):
            ArticleService.create_article(self=ArticleService(),
                                          account=self.publisher,
                                          article=self.article10)

        # try as an admin
        with self.assertRaises(ArticleMergeConflict):
            ArticleService.create_article(self=ArticleService(),
                                          account=self.admin,
                                          article=self.article10,
                                          update_article_id=self.article10.id)

    def test_04_old_doi_new_url(self):
        ba = self.article10.bibjson()
        ba.remove_urls(ba.FULLTEXT)
        ba.add_url("https://updated.com", ba.FULLTEXT)

        # try as publisher
        with self.assertRaises(DuplicateArticleException):
            ArticleService.create_article(self=ArticleService(),
                                          account=self.publisher,
                                          article=self.article10)

        # try as an admin
        resp = ArticleService.create_article(
            self=ArticleService(),
            account=self.admin,
            article=self.article10,
            update_article_id=self.article10.id)

        assert resp["success"] == 1, "expected 1 updated, received: {}".format(
            resp)
        assert resp["update"] == 1, "expected 1 updated, received: {}".format(
            resp)
        assert resp["new"] == 0, "expected 1 new, received: {}".format(resp)
        assert self.article10.get_normalised_fulltext(
        ) == "//updated.com", "expected //updated.com, received: {}".format(
            self.article10.get_normalised_fulltext())

    def test_05_new_doi_old_url(self):
        ba = self.article10.bibjson()
        ba.remove_identifiers(ba.DOI)
        ba.add_identifier(ba.DOI, "10.0000/article-UPDATED")

        # try as publisher
        with self.assertRaises(DuplicateArticleException):
            ArticleService.create_article(self=ArticleService(),
                                          account=self.publisher,
                                          article=self.article10)

        # try as an admin
        resp = ArticleService.create_article(
            self=ArticleService(),
            account=self.admin,
            article=self.article10,
            update_article_id=self.article10.id)

        assert resp["success"] == 1, "expected 1 updated, received: {}".format(
            resp)
        assert resp["update"] == 1, "expected 1 updated, received: {}".format(
            resp)
        assert resp["new"] == 0, "expected 1 updated, received: {}".format(
            resp)
        assert self.article10.get_normalised_doi() == "10.0000/article-UPDATED", \
            "expected 10.0000/article-UPDATED, received: {}".format(
                self.article10.get_normalised_fulltext())

    def test_06_existing_doi_new_url(self):
        ba = self.article10.bibjson()
        ba.remove_urls(ba.FULLTEXT)
        ba.add_url("https://updated.com", ba.FULLTEXT)
        # check for doi from other article of the same publisher
        ba.remove_identifiers(ba.DOI)
        ba.add_identifier(ba.DOI,
                          self.article11.bibjson().get_one_identifier(ba.DOI))

        # try as publisher
        with self.assertRaises(DuplicateArticleException):
            ArticleService.create_article(self=ArticleService(),
                                          account=self.publisher,
                                          article=self.article10)

        with self.assertRaises(DuplicateArticleException):
            ArticleService.create_article(self=ArticleService(),
                                          account=self.admin,
                                          article=self.article10,
                                          update_article_id=self.article10.id)

    def test_07_new_doi_existing_url(self):
        ba = self.article10.bibjson()
        ba.remove_urls(ba.FULLTEXT)
        ba.add_url(self.article11.bibjson().get_single_url(ba.FULLTEXT),
                   ba.FULLTEXT)
        # check for doi from other article of the same publisher
        ba.remove_identifiers(ba.DOI)
        ba.add_identifier(ba.DOI, "10.0000/article-UPDATED")

        # try as publisher
        with self.assertRaises(DuplicateArticleException):
            ArticleService.create_article(self=ArticleService(),
                                          account=self.publisher,
                                          article=self.article10)

        # try as an admin
        with self.assertRaises(DuplicateArticleException):
            ArticleService.create_article(self=ArticleService(),
                                          account=self.admin,
                                          article=self.article10,
                                          update_article_id=self.article10.id)
    def test_01_update_request(self, name, journal_id, journal_lock, account,
                               account_role, account_is_owner,
                               current_applications, application_lock,
                               application_status, completed_applications,
                               raises, return_app, return_jlock, return_alock,
                               db_jlock, db_alock, db_app):

        ###############################################
        ## set up

        # create the journal
        journal = None
        jid = None
        if journal_id == "valid":
            journal = Journal(**JournalFixtureFactory.make_journal_source(
                in_doaj=True))
            journal.remove_related_applications()
            journal.remove_current_application()
            jid = journal.id
        elif journal_id == "not_in_doaj":
            journal = Journal(**JournalFixtureFactory.make_journal_source(
                in_doaj=False))
            journal.remove_related_applications()
            journal.remove_current_application()
            jid = journal.id
        elif journal_id == "missing":
            jid = uuid.uuid4().hex

        acc = None
        if account == "yes":
            acc = Account(**AccountFixtureFactory.make_publisher_source())
            if account_role == "none":
                acc.remove_role("publisher")
            elif account_role == "admin":
                acc.remove_role("publisher")
                acc.add_role("admin")
            acc.set_id(acc.makeid())
            if account_is_owner == "yes":
                acc.set_id(journal.owner)

        if journal_lock == "yes":
            lock.lock("journal", jid, "someoneelse", blocking=True)

        latest_app = None
        current_app_count = int(current_applications)
        for i in range(current_app_count):
            app = Suggestion(
                **ApplicationFixtureFactory.make_application_source())
            app.set_id(app.makeid())
            app.set_created("198" + str(i) + "-01-01T00:00:00Z")
            app.set_current_journal(jid)
            app.save()
            latest_app = app
            if journal is not None:
                journal.set_current_application(app.id)

        comp_app_count = int(completed_applications)
        for i in range(comp_app_count):
            app = Suggestion(
                **ApplicationFixtureFactory.make_application_source())
            app.set_id(app.makeid())
            app.set_created("197" + str(i) + "-01-01T00:00:00Z")
            app.set_related_journal(jid)
            app.save()
            if journal is not None:
                journal.add_related_application(app.id,
                                                date_accepted=app.created_date)

        if current_app_count == 0 and comp_app_count == 0:
            # save at least one record to initialise the index mapping, otherwise tests fail
            app = Suggestion(
                **ApplicationFixtureFactory.make_application_source())
            app.set_id(app.makeid())
            app.save()

        if application_lock == "yes":
            lock.lock("suggestion",
                      latest_app.id,
                      "someoneelse",
                      blocking=True)

        if application_status != "n/a":
            latest_app.set_application_status(application_status)
            latest_app.save(blocking=True)

        # finally save the journal record, ensuring we get a blocking save, so everything
        # above here should be synchronised with the repo
        if journal is not None:
            journal.save(blocking=True)

        ###########################################################
        # Execution

        svc = DOAJ.applicationService()
        if raises != "":
            with self.assertRaises(EXCEPTIONS[raises]):
                svc.update_request_for_journal(jid, acc)
        else:
            application, jlock, alock = svc.update_request_for_journal(
                jid, acc)

            # we need to sleep, so the index catches up
            time.sleep(1)

            if return_app == "none":
                assert application is None
            elif return_app == "yes":
                assert application is not None

            if return_jlock == "none":
                assert jlock is None
            elif return_jlock == "yes":
                assert jlock is not None

            if return_alock == "none":
                assert alock is None
            elif return_alock == "yes":
                assert alock is not None

            if db_jlock == "no" and acc is not None:
                assert not lock.has_lock("journal", jid, acc.id)
            elif db_jlock == "yes" and acc is not None:
                l = lock.has_lock("journal", jid, acc.id)
                assert lock.has_lock("journal", jid, acc.id)

            if db_alock == "no" and application.id is not None and acc is not None:
                assert not lock.has_lock("suggestion", application.id, acc.id)
            elif db_alock == "yes" and application.id is not None and acc is not None:
                assert lock.has_lock("suggestion", application.id, acc.id)

            if db_app == "no" and application.id is not None:
                indb = Suggestion.q2obj(q="id.exact:" + application.id)
                assert indb is None
            elif db_app == "yes" and application.id is not None:
                indb = Suggestion.q2obj(q="id.exact:" + application.id)
                assert indb is not None

            if current_app_count == 0 and comp_app_count == 0 and application is not None:
                assert application.article_metadata is None
                assert application.articles_last_year is None
            elif application is not None:
                assert application.article_metadata is not None
                assert application.articles_last_year is not None
Exemple #6
0
def create_edit_cases():
    application_source = ApplicationFixtureFactory.make_application_source()
    account_source = AccountFixtureFactory.make_publisher_source()

    editable_application = Suggestion(**application_source)
    editable_application.set_application_status(
        constants.APPLICATION_STATUS_UPDATE_REQUEST)

    non_editable_application = Suggestion(**application_source)
    non_editable_application.set_application_status(
        constants.APPLICATION_STATUS_READY)

    owner_account = Account(**deepcopy(account_source))
    owner_account.set_id(editable_application.owner)

    non_owner_publisher = Account(**deepcopy(account_source))

    non_publisher = Account(**deepcopy(account_source))
    non_publisher.remove_role("publisher")

    admin = Account(**deepcopy(account_source))
    admin.add_role("admin")

    return [
        param("no_app_no_account",
              None,
              None,
              raises=exceptions.ArgumentException),
        param("no_app_with_account",
              None,
              owner_account,
              raises=exceptions.ArgumentException),
        param("app_no_account",
              editable_application,
              None,
              raises=exceptions.ArgumentException),
        param("editable_app_owning_account",
              editable_application,
              owner_account,
              expected=True),
        param("editable_app_nonowning_account",
              editable_application,
              non_owner_publisher,
              raises=exceptions.AuthoriseException),
        param("editable_app_non_publisher_account",
              editable_application,
              non_publisher,
              raises=exceptions.AuthoriseException),
        param("editable_app_admin_account",
              editable_application,
              admin,
              expected=True),
        param("non_editable_app_owning_account",
              non_editable_application,
              owner_account,
              raises=exceptions.AuthoriseException),
        param("non_editable_app_nonowning_account",
              non_editable_application,
              non_owner_publisher,
              raises=exceptions.AuthoriseException),
        param("non_editable_app_non_publisher_account",
              non_editable_application,
              non_publisher,
              raises=exceptions.AuthoriseException),
        param("non_editable_app_admin_account",
              non_editable_application,
              admin,
              expected=True)
    ]
Exemple #7
0
    def test_01_update_request(self, name, journal_id, journal_lock,
                               account, account_role, account_is_owner,
                               current_applications, application_lock, application_status,
                               completed_applications, raises,
                               return_app, return_jlock, return_alock,
                               db_jlock, db_alock, db_app):

        ###############################################
        ## set up

        # create the journal
        journal = None
        jid = None
        if journal_id == "valid":
            journal = Journal(**JournalFixtureFactory.make_journal_source(in_doaj=True))
            journal.remove_related_applications()
            journal.remove_current_application()
            jid = journal.id
        elif journal_id == "not_in_doaj":
            journal = Journal(**JournalFixtureFactory.make_journal_source(in_doaj=False))
            journal.remove_related_applications()
            journal.remove_current_application()
            jid = journal.id
        elif journal_id == "missing":
            jid = uuid.uuid4().hex

        acc = None
        if account == "yes":
            acc = Account(**AccountFixtureFactory.make_publisher_source())
            if account_role == "none":
                acc.remove_role("publisher")
            elif account_role == "admin":
                acc.remove_role("publisher")
                acc.add_role("admin")
            acc.set_id(acc.makeid())
            if account_is_owner == "yes":
                acc.set_id(journal.owner)

        if journal_lock == "yes":
            lock.lock("journal", jid, "someoneelse", blocking=True)

        latest_app = None
        current_app_count = int(current_applications)
        for i in range(current_app_count):
            app = Suggestion(**ApplicationFixtureFactory.make_application_source())
            app.set_id(app.makeid())
            app.set_created("198" + str(i) + "-01-01T00:00:00Z")
            app.set_current_journal(jid)
            app.save()
            latest_app = app
            if journal is not None:
                journal.set_current_application(app.id)

        comp_app_count = int(completed_applications)
        for i in range(comp_app_count):
            app = Suggestion(**ApplicationFixtureFactory.make_application_source())
            app.set_id(app.makeid())
            app.set_created("197" + str(i) + "-01-01T00:00:00Z")
            app.set_related_journal(jid)
            app.save()
            if journal is not None:
                journal.add_related_application(app.id, date_accepted=app.created_date)

        if current_app_count == 0 and comp_app_count == 0:
            # save at least one record to initialise the index mapping, otherwise tests fail
            app = Suggestion(**ApplicationFixtureFactory.make_application_source())
            app.set_id(app.makeid())
            app.save()

        if application_lock == "yes":
            lock.lock("suggestion", latest_app.id, "someoneelse", blocking=True)

        if application_status != "n/a":
            latest_app.set_application_status(application_status)
            latest_app.save(blocking=True)

        # finally save the journal record, ensuring we get a blocking save, so everything
        # above here should be synchronised with the repo
        if journal is not None:
            journal.save(blocking=True)

        ###########################################################
        # Execution

        svc = DOAJ.applicationService()
        if raises != "":
            with self.assertRaises(EXCEPTIONS[raises]):
                svc.update_request_for_journal(jid, acc)
        else:
            application, jlock, alock = svc.update_request_for_journal(jid, acc)

            # we need to sleep, so the index catches up
            time.sleep(1)

            if return_app == "none":
                assert application is None
            elif return_app == "yes":
                assert application is not None

            if return_jlock == "none":
                assert jlock is None
            elif return_jlock == "yes":
                assert jlock is not None

            if return_alock == "none":
                assert alock is None
            elif return_alock == "yes":
                assert alock is not None

            if db_jlock == "no" and acc is not None:
                assert not lock.has_lock("journal", jid, acc.id)
            elif db_jlock == "yes" and acc is not None:
                assert lock.has_lock("journal", jid, acc.id)

            if db_alock == "no" and application.id is not None and acc is not None:
                assert not lock.has_lock("suggestion", application.id, acc.id)
            elif db_alock == "yes" and application.id is not None and acc is not None:
                assert lock.has_lock("suggestion", application.id, acc.id)

            if db_app == "no" and application.id is not None:
                indb = Suggestion.q2obj(q="id.exact:" + application.id)
                assert indb is None
            elif db_app == "yes" and application.id is not None:
                indb = Suggestion.q2obj(q="id.exact:" + application.id)
                assert indb is not None

            if current_app_count == 0 and comp_app_count == 0 and application is not None:
                assert application.article_metadata is None
                assert application.articles_last_year is None
            elif application is not None:
                assert application.article_metadata is not None
                assert application.articles_last_year is not None