Browse Source

Change method name from create to save

pull/1823/head
Hironsan 2 years ago
parent
commit
0ef9e12810
2 changed files with 3 additions and 3 deletions
  1. 2
      backend/data_import/pipeline/label_types.py
  2. 4
      backend/data_import/tests/test_label_types.py

2
backend/data_import/pipeline/label_types.py

@ -12,7 +12,7 @@ class LabelTypes:
def __contains__(self, text: str) -> bool:
return text in self.types
def create(self, label_types: List[LabelType]):
def save(self, label_types: List[LabelType]):
self.label_type_class.objects.bulk_create(label_types, ignore_conflicts=True)
def update(self, project: Project):

4
backend/data_import/tests/test_label_types.py

@ -16,7 +16,7 @@ class TestCategoryLabel(TestCase):
def test_create(self):
label_types = LabelTypes(CategoryType)
category_types = [CategoryType(text="A", project=self.project.item)]
label_types.create(category_types)
label_types.save(category_types)
self.assertEqual(CategoryType.objects.count(), 1)
self.assertEqual(CategoryType.objects.first().text, "A")
@ -25,7 +25,7 @@ class TestCategoryLabel(TestCase):
with self.assertRaises(KeyError):
label_types.get_by_text("A")
category_types = [CategoryType(text="A", project=self.project.item)]
label_types.create(category_types)
label_types.save(category_types)
label_types.update(self.project.item)
category_type = label_types.get_by_text("A")
self.assertEqual(category_type.text, "A")
Loading…
Cancel
Save