Commit d955fc90 authored by Kenzo-Hugo Hillion's avatar Kenzo-Hugo Hillion
Browse files

fix tests

parent b9bdbc35
Pipeline #14146 passed with stages
in 1 minute and 49 seconds
......@@ -44,11 +44,11 @@ class BulkListSerializer(serializers.ListSerializer):
ModelClass = self.Meta.model
info = model_meta.get_field_info(ModelClass)
db_index_fields = self._get_db_index_fields(info)
updated_keys = self._get_all_key_fields(validated_data)
[data.pop(db_index_fields[0]) for data in validated_data] # remove db_index fields
for instance, validated_data_element in zip(instances, validated_data):
for key, value in validated_data_element.items():
setattr(instance, key, value)
updated_keys = self._get_all_key_fields(validated_data)
instances = ModelClass.objects.bulk_update(
instances,
updated_keys
......
......@@ -66,7 +66,8 @@ class TestGetDbIndexFields(BaseTestBulkListSerializerMethods):
def test_get_db_index_fields(self):
expected_keys = ['field1', 'field2']
tested_keys = self.bulk_list_serializer._get_all_key_fields(self.data)
self.assertListEqual(tested_keys, expected_keys)
for key in expected_keys:
self.assertIn(key, tested_keys)
class TestGetKeyFields(BaseTestBulkListSerializerMethods):
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment