| Conditions | 6 |
| Total Lines | 33 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 4 | ||
| Bugs | 0 | Features | 0 |
| 1 | from django.db import models |
||
| 13 | @staticmethod |
||
| 14 | def test_localized_bulk_insert(): |
||
| 15 | """Tests whether bulk inserts work properly when using |
||
| 16 | a :see:LocalizedUniqueSlugField in the model.""" |
||
| 17 | |||
| 18 | model = get_fake_model( |
||
| 19 | 'BulkSlugInsertModel', |
||
| 20 | { |
||
| 21 | 'name': LocalizedField(), |
||
| 22 | 'slug': LocalizedUniqueSlugField(populate_from='name', include_time=True), |
||
| 23 | 'score': models.IntegerField() |
||
| 24 | } |
||
| 25 | ) |
||
| 26 | |||
| 27 | to_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 | model.objects.bulk_create(to_create) |
||
| 34 | assert model.objects.all().count() == 3 |
||
| 35 | |||
| 36 | for obj in to_create: |
||
| 37 | obj_db = model.objects.filter( |
||
| 38 | name__en=obj.name.en, |
||
| 39 | name__ro=obj.name.ro, |
||
| 40 | score=obj.score |
||
| 41 | ).first() |
||
| 42 | |||
| 43 | assert obj_db |
||
| 44 | assert len(obj_db.slug.en) >= len(obj_db.name.en) |
||
| 45 | assert len(obj_db.slug.ro) >= len(obj_db.name.ro) |
||
| 46 |
This can be caused by one of the following:
1. Missing Dependencies
This error could indicate a configuration issue of Pylint. Make sure that your libraries are available by adding the necessary commands.
2. Missing __init__.py files
This error could also result from missing
__init__.pyfiles in your module folders. Make sure that you place one file in each sub-folder.