| Total Complexity | 2 |
| Total Lines | 21 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | import json |
||
| 13 | class LocalizedBulkTestCase(TestCase): |
||
| 14 | """Tests bulk operations with data structures provided |
||
| 15 | by the django-localized-fields library.""" |
||
| 16 | |||
| 17 | @staticmethod |
||
| 18 | def test_localized_bulk_insert(): |
||
| 19 | model = get_fake_model( |
||
| 20 | 'BulkInsertModel', |
||
| 21 | { |
||
| 22 | 'name': LocalizedField(), |
||
| 23 | 'score': models.IntegerField() |
||
| 24 | } |
||
| 25 | ) |
||
| 26 | |||
| 27 | objects = model.objects.bulk_create([ |
||
| 28 | model(name={'en': 'english name 1', 'ro': 'romanian name 1'}, score=1), |
||
| 29 | model(name={'en': 'english name 2', 'ro': 'romanian name 2'}, score=2), |
||
| 30 | model(name={'en': 'english name 3', 'ro': 'romanian name 3'}, score=3) |
||
| 31 | ]) |
||
| 32 | |||
| 33 | assert model.objects.all().count() == 3 |
||
| 34 |