Fix duplicate tag error (#65)

This commit is contained in:
Sascha Ißbrücker
2021-01-12 22:42:56 +01:00
committed by GitHub
parent f8fc360d84
commit 70953a52b9
3 changed files with 32 additions and 7 deletions

View File

@@ -42,6 +42,13 @@ class TagTestCase(TestCase):
self.assertEqual(len(tags), 1)
self.assertEqual(first_tag.id, second_tag.id)
def test_get_or_create_tag_should_handle_legacy_dbs_with_existing_duplicates(self):
Tag.objects.create(name='book', date_added=timezone.now(), owner=self.user)
Tag.objects.create(name='Book', date_added=timezone.now(), owner=self.user)
first_tag = get_or_create_tag('Book', self.user)
self.assertEqual(first_tag.id, first_tag.id)
def test_get_or_create_tags_should_return_tags(self):
books_tag = get_or_create_tag('Book', self.user)
movies_tag = get_or_create_tag('Movie', self.user)