Ejemplo n.º 1
0
 def test_description(self) -> None:
     file_id = 'BETTY01'
     file_path = Path('~')
     sut = File(file_id, file_path)
     self.assertIsNone(sut.description)
     description = 'Hi, my name is Betty!'
     sut.description = description
     self.assertEquals(description, sut.description)
Ejemplo n.º 2
0
def _load_object(loader: _Loader, element: ElementTree.Element,
                 gramps_tree_directory_path: Path):
    file_handle = element.get('handle')
    file_id = element.get('id')
    file_element = _xpath1(element, './ns:file')
    file_path = gramps_tree_directory_path / file_element.get('src')
    file = File(file_id, file_path)
    file.media_type = MediaType(file_element.get('mime'))
    description = file_element.get('description')
    if description:
        file.description = description
    _load_attribute_privacy(file, element, 'attribute')
    loader.add_entity(FlattenedEntity(file, file_handle))
    for citation_handle in _load_handles('citationref', element):
        loader.add_association(File, file_handle, 'citations', Citation,
                               citation_handle)
    for note_handle in _load_handles('noteref', element):
        loader.add_association(File, file_handle, 'notes', Note, note_handle)
Ejemplo n.º 3
0
    async def test_file(self, expected: str, locale: str):
        file_id = 'F1'
        file = File(file_id, __file__)
        file.description = '"file" is Dutch for "traffic jam"'

        with TemporaryDirectory() as output_directory_path:
            configuration = Configuration(output_directory_path,
                                          'https://example.com')
            configuration.locales.replace([
                LocaleConfiguration('en-US', 'en'),
                LocaleConfiguration('nl-NL', 'nl'),
            ])
            async with App(configuration).with_locale(locale) as app:
                app.ancestry.entities.append(file)
                indexed = [item for item in Index(app).build()]

        self.assertEquals('"file" is dutch for "traffic jam"',
                          indexed[0]['text'])
        self.assertIn(expected, indexed[0]['result'])