Add black code formatter

This commit is contained in:
Sascha Ißbrücker
2024-01-27 11:29:16 +01:00
parent 6775633be5
commit 98b9a9c1a0
128 changed files with 7181 additions and 4264 deletions

View File

@@ -26,65 +26,80 @@ class SettingsImportViewTestCase(TestCase, BookmarkFactoryMixin):
self.assertNotContains(response, '<div class="has-error">')
def test_should_import_successfully(self):
with open('bookmarks/tests/resources/simple_valid_import_file.html') as import_file:
with open(
"bookmarks/tests/resources/simple_valid_import_file.html"
) as import_file:
response = self.client.post(
reverse('bookmarks:settings.import'),
{'import_file': import_file},
follow=True
reverse("bookmarks:settings.import"),
{"import_file": import_file},
follow=True,
)
self.assertRedirects(response, reverse('bookmarks:settings.general'))
self.assertFormSuccessHint(response, '3 bookmarks were successfully imported')
self.assertRedirects(response, reverse("bookmarks:settings.general"))
self.assertFormSuccessHint(
response, "3 bookmarks were successfully imported"
)
self.assertNoFormErrorHint(response)
def test_should_check_authentication(self):
self.client.logout()
response = self.client.get(reverse('bookmarks:settings.import'), follow=True)
response = self.client.get(reverse("bookmarks:settings.import"), follow=True)
self.assertRedirects(response, reverse('login') + '?next=' + reverse('bookmarks:settings.import'))
def test_should_show_hint_if_there_is_no_file(self):
response = self.client.post(
reverse('bookmarks:settings.import'),
follow=True
self.assertRedirects(
response, reverse("login") + "?next=" + reverse("bookmarks:settings.import")
)
self.assertRedirects(response, reverse('bookmarks:settings.general'))
def test_should_show_hint_if_there_is_no_file(self):
response = self.client.post(reverse("bookmarks:settings.import"), follow=True)
self.assertRedirects(response, reverse("bookmarks:settings.general"))
self.assertNoFormSuccessHint(response)
self.assertFormErrorHint(response, 'Please select a file to import.')
self.assertFormErrorHint(response, "Please select a file to import.")
@disable_logging
def test_should_show_hint_if_import_raises_exception(self):
with open('bookmarks/tests/resources/invalid_import_file.png', 'rb') as import_file:
with open(
"bookmarks/tests/resources/invalid_import_file.png", "rb"
) as import_file:
response = self.client.post(
reverse('bookmarks:settings.import'),
{'import_file': import_file},
follow=True
reverse("bookmarks:settings.import"),
{"import_file": import_file},
follow=True,
)
self.assertRedirects(response, reverse('bookmarks:settings.general'))
self.assertRedirects(response, reverse("bookmarks:settings.general"))
self.assertNoFormSuccessHint(response)
self.assertFormErrorHint(response, 'An error occurred during bookmark import.')
self.assertFormErrorHint(
response, "An error occurred during bookmark import."
)
@disable_logging
def test_should_show_respective_hints_if_not_all_bookmarks_were_imported_successfully(self):
with open('bookmarks/tests/resources/simple_valid_import_file_with_one_invalid_bookmark.html') as import_file:
def test_should_show_respective_hints_if_not_all_bookmarks_were_imported_successfully(
self,
):
with open(
"bookmarks/tests/resources/simple_valid_import_file_with_one_invalid_bookmark.html"
) as import_file:
response = self.client.post(
reverse('bookmarks:settings.import'),
{'import_file': import_file},
follow=True
reverse("bookmarks:settings.import"),
{"import_file": import_file},
follow=True,
)
self.assertRedirects(response, reverse('bookmarks:settings.general'))
self.assertFormSuccessHint(response, '2 bookmarks were successfully imported')
self.assertFormErrorHint(response, '1 bookmarks could not be imported')
self.assertRedirects(response, reverse("bookmarks:settings.general"))
self.assertFormSuccessHint(
response, "2 bookmarks were successfully imported"
)
self.assertFormErrorHint(response, "1 bookmarks could not be imported")
def test_should_respect_map_private_flag_option(self):
with open('bookmarks/tests/resources/simple_valid_import_file.html') as import_file:
with open(
"bookmarks/tests/resources/simple_valid_import_file.html"
) as import_file:
self.client.post(
reverse('bookmarks:settings.import'),
{'import_file': import_file},
follow=True
reverse("bookmarks:settings.import"),
{"import_file": import_file},
follow=True,
)
self.assertEqual(Bookmark.objects.count(), 3)
@@ -94,11 +109,13 @@ class SettingsImportViewTestCase(TestCase, BookmarkFactoryMixin):
Bookmark.objects.all().delete()
with open('bookmarks/tests/resources/simple_valid_import_file.html') as import_file:
with open(
"bookmarks/tests/resources/simple_valid_import_file.html"
) as import_file:
self.client.post(
reverse('bookmarks:settings.import'),
{'import_file': import_file, 'map_private_flag': 'on'},
follow=True
reverse("bookmarks:settings.import"),
{"import_file": import_file, "map_private_flag": "on"},
follow=True,
)
self.assertEqual(Bookmark.objects.count(), 3)