Ejemplo n.º 1
0
    def test_new_version_automaticaly_references_latest_known_assets(self):
        manifest = {
            "id": "0034-8910-rsp-48-2-0275",
            "versions": [
                {
                    "data": "/rawfiles/7ca9f9b2687cb/0034-8910-rsp-48-2-0275.xml",
                    "assets": {
                        "0034-8910-rsp-48-2-0275-gf01.gif": [
                            (
                                "2018-08-05T23:03:44.971230Z",
                                "/rawfiles/8e644999a8fa4/0034-8910-rsp-48-2-0275-gf01.gif",
                            ),
                            (
                                "2018-08-05T23:03:49.971250Z",
                                "/rawfiles/bf139b9aa3066/0034-8910-rsp-48-2-0275-gf01.gif",
                            ),
                        ]
                    },
                }
            ],
        }

        document = domain.Document(manifest=manifest)
        document.new_version(
            "/rawfiles/2d3ad9c6bc656/0034-8910-rsp-48-2-0275.xml",
            assets_getter=lambda data_url, timeout: (
                None,
                [("0034-8910-rsp-48-2-0275-gf01.gif", None)],
            ),
        )
        latest = document.version()
        self.assertEqual(
            latest["assets"]["0034-8910-rsp-48-2-0275-gf01.gif"],
            "/rawfiles/bf139b9aa3066/0034-8910-rsp-48-2-0275-gf01.gif",
        )
Ejemplo n.º 2
0
 def setUp(self):
     self.services, self.session = make_services()
     self.manifest = {
         "id": "0034-8910-rsp-48-2-0347",
         "versions": [
             {
                 "data": "https://url.to/0034-8910-rsp-48-2-0347.xml",
                 "assets": {
                     "0034-8910-rsp-48-2-0347-gf01": [
                         [
                             "2018-08-05T23:03:44.971230Z",
                             "http://www.scielo.br/img/revistas/rsp/v48n2/0034-8910-rsp-48-2-0347-gf01.jpg",
                         ],
                     ],
                 },
                 "renditions": [],
             },
         ],
     }
     self.doc = domain.Document(manifest=self.manifest)
     self.session.documents.add(self.doc)
     self.command = self.services["register_document_version"]
Ejemplo n.º 3
0
 def test_id(self):
     document = domain.Document(id="0034-8910-rsp-48-2-0275")
     self.assertEqual(document.id(), "0034-8910-rsp-48-2-0275")
Ejemplo n.º 4
0
 def test_missing_id_return_empty_string(self):
     existing_manifest = {"versions": []}
     document = domain.Document(manifest=existing_manifest)
     self.assertEqual(document.id(), "")
Ejemplo n.º 5
0
 def test_manifest_with_unknown_schema_is_allowed(self):
     existing_manifest = {"versions": []}
     document = domain.Document(manifest=existing_manifest)
     self.assertEqual(existing_manifest, document.manifest)
Ejemplo n.º 6
0
 def test_manifest_as_arg_on_init(self):
     existing_manifest = {"id": "0034-8910-rsp-48-2-0275", "versions": []}
     document = domain.Document(manifest=existing_manifest)
     self.assertEqual(existing_manifest, document.manifest)
Ejemplo n.º 7
0
 def test_manifest_is_generated_on_init(self):
     document = domain.Document(id="0034-8910-rsp-48-2-0275")
     self.assertTrue(isinstance(document.manifest, dict))
Ejemplo n.º 8
0
 def make_one(self):
     _manifest = deepcopy(SAMPLE_MANIFEST)
     return domain.Document(manifest=_manifest)
Ejemplo n.º 9
0
 def test_get_latest_version_when_there_isnt_any(self):
     document = domain.Document(id="0034-8910-rsp-48-2-0275")
     self.assertRaises(ValueError, lambda: document.version())
Ejemplo n.º 10
0
 def setUp(self):
     self.services, self.session = make_services()
     self.command = self.services["register_rendition_version"]
     self.event = services.Events.RENDITION_VERSION_REGISTERED
     self.document = domain.Document(manifest=apptesting.manifest_data_fixture())
     self.session.documents.add(self.document)
Ejemplo n.º 11
0
 def setUp(self):
     self.services, self.session = make_services()
     self.command = self.services["delete_document"]
     self.document = domain.Document(manifest=apptesting.manifest_data_fixture())
     self.session.documents.add(self.document)
     self.event = services.Events.DOCUMENT_DELETED
Ejemplo n.º 12
0
 def setUp(self):
     self.services, self.session = make_services()
     self.command = self.services["fetch_document_renditions"]
     self.document = domain.Document(manifest=apptesting.manifest_data_fixture())
     self.session.documents.add(self.document)