Ejemplo n.º 1
0
 def test_create_aop_bundle_uses_scielo_ids_generator_aops_bundle_id(
         self, mk_aops_bundle_id):
     session_db = MagicMock()
     session_db.journals.fetch.return_value = inserting.ManifestDomainAdapter(
         manifest=SAMPLE_KERNEL_JOURNAL)
     inserting.create_aop_bundle(session_db, "0001-3714")
     mk_aops_bundle_id.assert_called_once_with("0001-3714")
Ejemplo n.º 2
0
 def test_create_aop_bundle_registers_aop_bundle(self,
                                                 MockManifestDomainAdapter,
                                                 mk_utcnow):
     mk_utcnow.return_value = "2019-01-02T05:00:00.000000Z"
     expected = {
         "_id": "0001-3714-aop",
         "created": "2019-01-02T05:00:00.000000Z",
         "updated": "2019-01-02T05:00:00.000000Z",
         "items": [],
         "metadata": {},
         "id": "0001-3714-aop",
     }
     mk_bundle_manifest = Mock()
     MockManifestDomainAdapter.return_value = mk_bundle_manifest
     session_db = MagicMock()
     session_db.journals.fetch.return_value = inserting.ManifestDomainAdapter(
         manifest=SAMPLE_KERNEL_JOURNAL)
     inserting.create_aop_bundle(session_db, SAMPLE_KERNEL_JOURNAL["id"])
     MockManifestDomainAdapter.assert_any_call(manifest=expected)
     session_db.documents_bundles.add.assert_called_once_with(
         data=mk_bundle_manifest)
     session_db.changes.add.assert_any_call({
         "timestamp": "2019-01-02T05:00:00.000000Z",
         "entity": "DocumentsBundle",
         "id": "0001-3714-aop",
     })
 def test_create_aop_bundle_gets_journal(
     self
 ):
     issn = "1234-0001"
     session_db = MagicMock()
     inserting.create_aop_bundle(session_db, issn)
     session_db.journals.fetch.assert_called_once_with(issn)
Ejemplo n.º 4
0
    def test_create_aop_bundle_links_aop_bundle_to_journal(self):
        session = Session()
        journal = Journal(manifest=SAMPLE_KERNEL_JOURNAL)
        session.journals.add(journal)

        inserting.create_aop_bundle(session, journal.id())
        self.assertEqual(
            session.journals.fetch(journal.id()).ahead_of_print_bundle,
            "0001-3714-aop")
Ejemplo n.º 5
0
 def test_create_aop_bundle_uses_scielo_ids_generator_aops_bundle_id(
         self, mk_aops_bundle_id, mock_gzip):
     mock_gzip.compress.return_value = "bla".encode("ascii")
     mk_aops_bundle_id.return_value = "bundle-01"
     session_db = MagicMock()
     session_db.journals.fetch.return_value = Journal(
         manifest=SAMPLE_KERNEL_JOURNAL)
     inserting.create_aop_bundle(session_db, "0001-3714")
     mk_aops_bundle_id.assert_called_once_with("0001-3714")
Ejemplo n.º 6
0
 def test_create_aop_bundle_returns_bundle(self):
     session_db = Session()
     session_db.journals.add(Journal(manifest=SAMPLE_KERNEL_JOURNAL))
     result = inserting.create_aop_bundle(session_db,
                                          SAMPLE_KERNEL_JOURNAL["id"])
     self.assertIsInstance(result, DocumentsBundle)
     self.assertEqual(result.id(), "0001-3714-aop")
Ejemplo n.º 7
0
 def test_create_aop_bundle_links_aop_bundle_to_journal(self, mk_utcnow):
     mk_utcnow.return_value = "2019-01-02T05:00:00.000000Z"
     mocked_journal_data = inserting.ManifestDomainAdapter(
         manifest=SAMPLE_KERNEL_JOURNAL)
     mk_bundle_manifest = Mock()
     session_db = MagicMock()
     session_db.journals.fetch.return_value = mocked_journal_data
     inserting.create_aop_bundle(session_db, SAMPLE_KERNEL_JOURNAL["id"])
     session_db.journals.update.assert_called()
     session_db.changes.add.assert_any_call({
         "timestamp":
         "2019-01-02T05:00:00.000000Z",
         "entity":
         "Journal",
         "id":
         SAMPLE_KERNEL_JOURNAL["id"],
     })
     self.assertEqual(mocked_journal_data.ahead_of_print_bundle,
                      "0001-3714-aop")
Ejemplo n.º 8
0
 def test_create_aop_bundle_gets_journal(self, mock_gzip):
     mock_gzip.compress.return_value = "bla".encode("ascii")
     issn = "1234-0001"
     session_db = MagicMock()
     inserting.create_aop_bundle(session_db, issn)
     session_db.journals.fetch.assert_called_once_with(issn)