from django.test import TestCase from django.utils import timezone from bookmarks.services import exporter from bookmarks.tests.helpers import BookmarkFactoryMixin class ExporterTestCase(TestCase, BookmarkFactoryMixin): def test_export_bookmarks(self): added = timezone.now() timestamp = int(added.timestamp()) bookmarks = [ self.setup_bookmark( url="https://example.com/1", title="Title 1", added=added, description="Example description", ), self.setup_bookmark( url="https://example.com/2", title="Title 2", added=added, tags=[ self.setup_tag(name="tag1"), self.setup_tag(name="tag2"), self.setup_tag(name="tag3"), ], ), self.setup_bookmark( url="https://example.com/3", title="Title 3", added=added, unread=True ), self.setup_bookmark( url="https://example.com/4", title="Title 4", added=added, shared=True ), self.setup_bookmark( url="https://example.com/5", title="Title 5", added=added, shared=True, description="Example description", notes="Example notes", ), self.setup_bookmark( url="https://example.com/6", title="Title 6", added=added, shared=True, notes="Example notes", ), self.setup_bookmark( url="https://example.com/7", title="Title 7", added=added, is_archived=True, ), self.setup_bookmark( url="https://example.com/8", title="Title 8", added=added, tags=[self.setup_tag(name="tag4"), self.setup_tag(name="tag5")], is_archived=True, ), ] html = exporter.export_netscape_html(bookmarks) lines = [ f'
Title 1', "
Example description", f'
Title 2', f'
Title 3', f'
Title 4', f'
Title 5', "
Example description[linkding-notes]Example notes[/linkding-notes]", f'
Title 6', "
[linkding-notes]Example notes[/linkding-notes]", f'
Title 7', f'
Title 8', ] self.assertIn("\n\r".join(lines), html) def test_escape_html(self): bookmark = self.setup_bookmark( title="