コード例 #1
0
def conversion_journal_to_bundle(journal: dict) -> None:
    """Transforma um objeto Journal (xylose) para o formato
    de dados equivalente ao persistido pelo Kernel em um banco
    mongodb"""

    _journal = Journal(journal)
    _bundle = xylose_converter.journal_to_kernel(_journal)
    return _bundle
コード例 #2
0
    def test_bundle_metadata_fields_timestamps_and_created_date_should_be_equals(
            self):
        journal = journal_to_kernel(self._journal)

        for field, value in journal.get("metadata").items():
            if field == "status":
                continue

            date = value[0][0]
            with self.subTest(date=date):
                self.assertEqual(journal.get("created"), date)
コード例 #3
0
 def test_journal_has_institution_responsible_for(self):
     journal = journal_to_kernel(self._journal)
     expected = tuple(
         [
             {
                 "name": "Sociedade Brasileira de Medicina Tropical - SBMT",
                 "country_code": "BR",
                 "country": "Brazil",
                 "state": "MG",
                 "city": "Uberaba",
             }
         ]
     )
     self.assertEqual(
         expected, get_metadata_item(journal, "institution_responsible_for")
     )
コード例 #4
0
    def test_journal_status_timestamps_should_be_different_from_created_date(
            self):
        journal = journal_to_kernel(self._journal)
        _status = journal["metadata"]["status"]

        self.assertNotEqual(journal["created"], _status[1][0])
コード例 #5
0
    def test_journal_has_status(self):
        journal = journal_to_kernel(self._journal)
        _status = journal["metadata"]["status"]

        self.assertEqual(2, len(_status))
        self.assertEqual("suspended-by-editor", _status[1][1]["reason"])
コード例 #6
0
 def test_journal_has_electronic_issn(self):
     journal = journal_to_kernel(self._journal)
     self.assertEqual("2448-167X",
                      get_metadata_item(journal, "electronic_issn"))
コード例 #7
0
 def test_journal_has_contact_email(self):
     journal = journal_to_kernel(self._journal)
     self.assertEqual("*****@*****.**", journal["metadata"]["contact"]["email"])
コード例 #8
0
 def test_journal_has_contact_address(self):
     journal = journal_to_kernel(self._journal)
     self.assertEqual(
         "Rua de exemplo, 1, São Paulo, SP, Brasil",
         get_metadata_item(journal, "contact")["address"],
     )
コード例 #9
0
 def test_journal_has_previous_journal(self):
     journal = journal_to_kernel(self._journal)
     self.assertIsNotNone(get_metadata_item(journal, "previous_journal"))
コード例 #10
0
 def test_journal_has_subject_categories(self):
     journal = journal_to_kernel(self._journal)
     self.assertEqual(["AREA"],
                      get_metadata_item(journal, "subject_categories"))
コード例 #11
0
 def test_journal_has_mission(self):
     journal = journal_to_kernel(self._journal)
     self.assertEqual(3, len(get_metadata_item(journal, "mission")))
コード例 #12
0
 def test_journal_hasnt_title(self):
     del self.json_journal["v100"]
     journal = journal_to_kernel(self._journal)
     self.assertIsNone(get_metadata_item(journal, "title"))
コード例 #13
0
 def test_raise_exception_if_journal_hasnt_id(self):
     with self.assertRaises(ValueError):
         del self.json_journal["v435"]
         del self.json_journal["v400"]
         journal_to_kernel(Journal(self.json_journal))
コード例 #14
0
 def test_bundle_id_joins_acronym_and_collection(self):
     journal = journal_to_kernel(self._journal)
     self.assertEqual("0001-3714", journal["id"])
     self.assertEqual("0001-3714", journal["_id"])
コード例 #15
0
 def test_journal_has_contact_address(self):
     journal = journal_to_kernel(self._journal)
     self.assertEqual(
         "Rua de exemplo, 1, São Paulo, SP, Brasil",
         journal["metadata"]["contact"]["address"],
     )
コード例 #16
0
 def test_journal_has_subject_areas(self):
     journal = journal_to_kernel(self._journal)
     self.assertEqual(["HEALTH SCIENCES"],
                      get_metadata_item(journal, "subject_areas"))
コード例 #17
0
 def test_journal_has_sponsors(self):
     journal = journal_to_kernel(self._journal)
     self.assertEqual([{
         "name": "SCIELO"
     }], get_metadata_item(journal, "sponsors"))
コード例 #18
0
 def test_journal_has_title_iso(self):
     journal = journal_to_kernel(self._journal)
     self.assertEqual("sample.", get_metadata_item(journal, "title_iso"))
コード例 #19
0
 def test_journal_has_online_submission_url(self):
     journal = journal_to_kernel(self._journal)
     self.assertIsNotNone(
         get_metadata_item(journal, "online_submission_url"))
コード例 #20
0
 def test_journal_has_short_title(self):
     journal = journal_to_kernel(self._journal)
     self.assertEqual("sample", get_metadata_item(journal, "short_title"))
コード例 #21
0
 def test_journal_has_contact_email(self):
     journal = journal_to_kernel(self._journal)
     self.assertEqual("*****@*****.**",
                      get_metadata_item(journal, "contact")["email"])
コード例 #22
0
 def test_journal_has_scielo_issn(self):
     journal = journal_to_kernel(self._journal)
     self.assertEqual("0001-3714",
                      get_metadata_item(journal, "scielo_issn"))
コード例 #23
0
 def test_journal_has_print_issn(self):
     journal = journal_to_kernel(self._journal)
     self.assertEqual("0001", get_metadata_item(journal, "print_issn"))
コード例 #24
0
 def test_journal_has_subject_areas(self):
     journal = journal_to_kernel(self._journal)
     self.assertEqual(
         ["Health Sciences"], get_metadata_item(journal, "subject_areas")
     )