~ubuntu-branches/debian/sid/python-django/sid

« back to all changes in this revision

Viewing changes to tests/admin_checks/tests.py

  • Committer: Package Import Robot
  • Author(s): Raphaël Hertzog
  • Date: 2014-09-17 14:15:11 UTC
  • mfrom: (1.3.17) (6.2.18 experimental)
  • Revision ID: package-import@ubuntu.com-20140917141511-icneokthe9ww5sk4
Tags: 1.7-2
* Release to unstable.
* Add a migrate-south sample script to help users apply their South
  migrations. Thanks to Brian May.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
from __future__ import unicode_literals
 
2
 
 
3
import warnings
 
4
 
 
5
from django import forms
 
6
from django.contrib import admin
 
7
from django.contrib.contenttypes.admin import GenericStackedInline
 
8
from django.core import checks
 
9
from django.core.exceptions import ImproperlyConfigured
 
10
from django.test import TestCase
 
11
 
 
12
from .models import Song, Book, Album, TwoAlbumFKAndAnE, City, State, Influence
 
13
 
 
14
 
 
15
class SongForm(forms.ModelForm):
 
16
    pass
 
17
 
 
18
 
 
19
class ValidFields(admin.ModelAdmin):
 
20
    form = SongForm
 
21
    fields = ['title']
 
22
 
 
23
 
 
24
class ValidFormFieldsets(admin.ModelAdmin):
 
25
    def get_form(self, request, obj=None, **kwargs):
 
26
        class ExtraFieldForm(SongForm):
 
27
            name = forms.CharField(max_length=50)
 
28
        return ExtraFieldForm
 
29
 
 
30
    fieldsets = (
 
31
        (None, {
 
32
            'fields': ('name',),
 
33
        }),
 
34
    )
 
35
 
 
36
 
 
37
class SystemChecksTestCase(TestCase):
 
38
 
 
39
    def test_checks_are_performed(self):
 
40
        class MyAdmin(admin.ModelAdmin):
 
41
            @classmethod
 
42
            def check(self, model, **kwargs):
 
43
                return ['error!']
 
44
 
 
45
        admin.site.register(Song, MyAdmin)
 
46
        try:
 
47
            errors = checks.run_checks()
 
48
            expected = ['error!']
 
49
            self.assertEqual(errors, expected)
 
50
        finally:
 
51
            admin.site.unregister(Song)
 
52
 
 
53
    def test_readonly_and_editable(self):
 
54
        class SongAdmin(admin.ModelAdmin):
 
55
            readonly_fields = ["original_release"]
 
56
            list_display = ["pk", "original_release"]
 
57
            list_editable = ["original_release"]
 
58
            fieldsets = [
 
59
                (None, {
 
60
                    "fields": ["title", "original_release"],
 
61
                }),
 
62
            ]
 
63
 
 
64
        errors = SongAdmin.check(model=Song)
 
65
        expected = [
 
66
            checks.Error(
 
67
                ("The value of 'list_editable[0]' refers to 'original_release', "
 
68
                 "which is not editable through the admin."),
 
69
                hint=None,
 
70
                obj=SongAdmin,
 
71
                id='admin.E125',
 
72
            )
 
73
        ]
 
74
        self.assertEqual(errors, expected)
 
75
 
 
76
    def test_editable(self):
 
77
        class SongAdmin(admin.ModelAdmin):
 
78
            list_display = ["pk", "title"]
 
79
            list_editable = ["title"]
 
80
            fieldsets = [
 
81
                (None, {
 
82
                    "fields": ["title", "original_release"],
 
83
                }),
 
84
            ]
 
85
 
 
86
        errors = SongAdmin.check(model=Song)
 
87
        self.assertEqual(errors, [])
 
88
 
 
89
    def test_custom_modelforms_with_fields_fieldsets(self):
 
90
        """
 
91
        # Regression test for #8027: custom ModelForms with fields/fieldsets
 
92
        """
 
93
 
 
94
        errors = ValidFields.check(model=Song)
 
95
        self.assertEqual(errors, [])
 
96
 
 
97
    def test_custom_get_form_with_fieldsets(self):
 
98
        """
 
99
        Ensure that the fieldsets checks are skipped when the ModelAdmin.get_form() method
 
100
        is overridden.
 
101
        Refs #19445.
 
102
        """
 
103
 
 
104
        errors = ValidFormFieldsets.check(model=Song)
 
105
        self.assertEqual(errors, [])
 
106
 
 
107
    def test_exclude_values(self):
 
108
        """
 
109
        Tests for basic system checks of 'exclude' option values (#12689)
 
110
        """
 
111
 
 
112
        class ExcludedFields1(admin.ModelAdmin):
 
113
            exclude = 'foo'
 
114
 
 
115
        errors = ExcludedFields1.check(model=Book)
 
116
        expected = [
 
117
            checks.Error(
 
118
                "The value of 'exclude' must be a list or tuple.",
 
119
                hint=None,
 
120
                obj=ExcludedFields1,
 
121
                id='admin.E014',
 
122
            )
 
123
        ]
 
124
        self.assertEqual(errors, expected)
 
125
 
 
126
    def test_exclude_duplicate_values(self):
 
127
        class ExcludedFields2(admin.ModelAdmin):
 
128
            exclude = ('name', 'name')
 
129
 
 
130
        errors = ExcludedFields2.check(model=Book)
 
131
        expected = [
 
132
            checks.Error(
 
133
                "The value of 'exclude' contains duplicate field(s).",
 
134
                hint=None,
 
135
                obj=ExcludedFields2,
 
136
                id='admin.E015',
 
137
            )
 
138
        ]
 
139
        self.assertEqual(errors, expected)
 
140
 
 
141
    def test_exclude_in_inline(self):
 
142
        class ExcludedFieldsInline(admin.TabularInline):
 
143
            model = Song
 
144
            exclude = 'foo'
 
145
 
 
146
        class ExcludedFieldsAlbumAdmin(admin.ModelAdmin):
 
147
            model = Album
 
148
            inlines = [ExcludedFieldsInline]
 
149
 
 
150
        errors = ExcludedFieldsAlbumAdmin.check(model=Album)
 
151
        expected = [
 
152
            checks.Error(
 
153
                "The value of 'exclude' must be a list or tuple.",
 
154
                hint=None,
 
155
                obj=ExcludedFieldsInline,
 
156
                id='admin.E014',
 
157
            )
 
158
        ]
 
159
        self.assertEqual(errors, expected)
 
160
 
 
161
    def test_exclude_inline_model_admin(self):
 
162
        """
 
163
        Regression test for #9932 - exclude in InlineModelAdmin should not
 
164
        contain the ForeignKey field used in ModelAdmin.model
 
165
        """
 
166
 
 
167
        class SongInline(admin.StackedInline):
 
168
            model = Song
 
169
            exclude = ['album']
 
170
 
 
171
        class AlbumAdmin(admin.ModelAdmin):
 
172
            model = Album
 
173
            inlines = [SongInline]
 
174
 
 
175
        errors = AlbumAdmin.check(model=Album)
 
176
        expected = [
 
177
            checks.Error(
 
178
                ("Cannot exclude the field 'album', because it is the foreign key "
 
179
                 "to the parent model 'admin_checks.Album'."),
 
180
                hint=None,
 
181
                obj=SongInline,
 
182
                id='admin.E201',
 
183
            )
 
184
        ]
 
185
        self.assertEqual(errors, expected)
 
186
 
 
187
    def test_valid_generic_inline_model_admin(self):
 
188
        """
 
189
        Regression test for #22034 - check that generic inlines don't look for
 
190
        normal ForeignKey relations.
 
191
        """
 
192
 
 
193
        class InfluenceInline(GenericStackedInline):
 
194
            model = Influence
 
195
 
 
196
        class SongAdmin(admin.ModelAdmin):
 
197
            inlines = [InfluenceInline]
 
198
 
 
199
        errors = SongAdmin.check(model=Song)
 
200
        self.assertEqual(errors, [])
 
201
 
 
202
    def test_generic_inline_model_admin_non_generic_model(self):
 
203
        """
 
204
        Ensure that a model without a GenericForeignKey raises problems if it's included
 
205
        in an GenericInlineModelAdmin definition.
 
206
        """
 
207
 
 
208
        class BookInline(GenericStackedInline):
 
209
            model = Book
 
210
 
 
211
        class SongAdmin(admin.ModelAdmin):
 
212
            inlines = [BookInline]
 
213
 
 
214
        errors = SongAdmin.check(model=Song)
 
215
        expected = [
 
216
            checks.Error(
 
217
                "'admin_checks.Book' has no GenericForeignKey.",
 
218
                hint=None,
 
219
                obj=BookInline,
 
220
                id='admin.E301',
 
221
            )
 
222
        ]
 
223
        self.assertEqual(errors, expected)
 
224
 
 
225
    def test_generic_inline_model_admin_bad_ct_field(self):
 
226
        "A GenericInlineModelAdmin raises problems if the ct_field points to a non-existent field."
 
227
 
 
228
        class InfluenceInline(GenericStackedInline):
 
229
            model = Influence
 
230
            ct_field = 'nonexistent'
 
231
 
 
232
        class SongAdmin(admin.ModelAdmin):
 
233
            inlines = [InfluenceInline]
 
234
 
 
235
        errors = SongAdmin.check(model=Song)
 
236
        expected = [
 
237
            checks.Error(
 
238
                "'ct_field' references 'nonexistent', which is not a field on 'admin_checks.Influence'.",
 
239
                hint=None,
 
240
                obj=InfluenceInline,
 
241
                id='admin.E302',
 
242
            )
 
243
        ]
 
244
        self.assertEqual(errors, expected)
 
245
 
 
246
    def test_generic_inline_model_admin_bad_fk_field(self):
 
247
        "A GenericInlineModelAdmin raises problems if the ct_fk_field points to a non-existent field."
 
248
 
 
249
        class InfluenceInline(GenericStackedInline):
 
250
            model = Influence
 
251
            ct_fk_field = 'nonexistent'
 
252
 
 
253
        class SongAdmin(admin.ModelAdmin):
 
254
            inlines = [InfluenceInline]
 
255
 
 
256
        errors = SongAdmin.check(model=Song)
 
257
        expected = [
 
258
            checks.Error(
 
259
                "'ct_fk_field' references 'nonexistent', which is not a field on 'admin_checks.Influence'.",
 
260
                hint=None,
 
261
                obj=InfluenceInline,
 
262
                id='admin.E303',
 
263
            )
 
264
        ]
 
265
        self.assertEqual(errors, expected)
 
266
 
 
267
    def test_generic_inline_model_admin_non_gfk_ct_field(self):
 
268
        "A GenericInlineModelAdmin raises problems if the ct_field points to a field that isn't part of a GenericForeignKey"
 
269
 
 
270
        class InfluenceInline(GenericStackedInline):
 
271
            model = Influence
 
272
            ct_field = 'name'
 
273
 
 
274
        class SongAdmin(admin.ModelAdmin):
 
275
            inlines = [InfluenceInline]
 
276
 
 
277
        errors = SongAdmin.check(model=Song)
 
278
        expected = [
 
279
            checks.Error(
 
280
                "'admin_checks.Influence' has no GenericForeignKey using content type field 'name' and object ID field 'object_id'.",
 
281
                hint=None,
 
282
                obj=InfluenceInline,
 
283
                id='admin.E304',
 
284
            )
 
285
        ]
 
286
        self.assertEqual(errors, expected)
 
287
 
 
288
    def test_generic_inline_model_admin_non_gfk_fk_field(self):
 
289
        "A GenericInlineModelAdmin raises problems if the ct_fk_field points to a field that isn't part of a GenericForeignKey"
 
290
 
 
291
        class InfluenceInline(GenericStackedInline):
 
292
            model = Influence
 
293
            ct_fk_field = 'name'
 
294
 
 
295
        class SongAdmin(admin.ModelAdmin):
 
296
            inlines = [InfluenceInline]
 
297
 
 
298
        errors = SongAdmin.check(model=Song)
 
299
        expected = [
 
300
            checks.Error(
 
301
                "'admin_checks.Influence' has no GenericForeignKey using content type field 'content_type' and object ID field 'name'.",
 
302
                hint=None,
 
303
                obj=InfluenceInline,
 
304
                id='admin.E304',
 
305
            )
 
306
        ]
 
307
        self.assertEqual(errors, expected)
 
308
 
 
309
    def test_app_label_in_admin_checks(self):
 
310
        """
 
311
        Regression test for #15669 - Include app label in admin system check messages
 
312
        """
 
313
 
 
314
        class RawIdNonexistingAdmin(admin.ModelAdmin):
 
315
            raw_id_fields = ('nonexisting',)
 
316
 
 
317
        errors = RawIdNonexistingAdmin.check(model=Album)
 
318
        expected = [
 
319
            checks.Error(
 
320
                ("The value of 'raw_id_fields[0]' refers to 'nonexisting', which is "
 
321
                 "not an attribute of 'admin_checks.Album'."),
 
322
                hint=None,
 
323
                obj=RawIdNonexistingAdmin,
 
324
                id='admin.E002',
 
325
            )
 
326
        ]
 
327
        self.assertEqual(errors, expected)
 
328
 
 
329
    def test_fk_exclusion(self):
 
330
        """
 
331
        Regression test for #11709 - when testing for fk excluding (when exclude is
 
332
        given) make sure fk_name is honored or things blow up when there is more
 
333
        than one fk to the parent model.
 
334
        """
 
335
 
 
336
        class TwoAlbumFKAndAnEInline(admin.TabularInline):
 
337
            model = TwoAlbumFKAndAnE
 
338
            exclude = ("e",)
 
339
            fk_name = "album1"
 
340
 
 
341
        class MyAdmin(admin.ModelAdmin):
 
342
            inlines = [TwoAlbumFKAndAnEInline]
 
343
 
 
344
        errors = MyAdmin.check(model=Album)
 
345
        self.assertEqual(errors, [])
 
346
 
 
347
    def test_inline_self_check(self):
 
348
        class TwoAlbumFKAndAnEInline(admin.TabularInline):
 
349
            model = TwoAlbumFKAndAnE
 
350
 
 
351
        class MyAdmin(admin.ModelAdmin):
 
352
            inlines = [TwoAlbumFKAndAnEInline]
 
353
 
 
354
        errors = MyAdmin.check(model=Album)
 
355
        expected = [
 
356
            checks.Error(
 
357
                "'admin_checks.TwoAlbumFKAndAnE' has more than one ForeignKey to 'admin_checks.Album'.",
 
358
                hint=None,
 
359
                obj=TwoAlbumFKAndAnEInline,
 
360
                id='admin.E202',
 
361
            )
 
362
        ]
 
363
        self.assertEqual(errors, expected)
 
364
 
 
365
    def test_inline_with_specified(self):
 
366
        class TwoAlbumFKAndAnEInline(admin.TabularInline):
 
367
            model = TwoAlbumFKAndAnE
 
368
            fk_name = "album1"
 
369
 
 
370
        class MyAdmin(admin.ModelAdmin):
 
371
            inlines = [TwoAlbumFKAndAnEInline]
 
372
 
 
373
        errors = MyAdmin.check(model=Album)
 
374
        self.assertEqual(errors, [])
 
375
 
 
376
    def test_readonly(self):
 
377
        class SongAdmin(admin.ModelAdmin):
 
378
            readonly_fields = ("title",)
 
379
 
 
380
        errors = SongAdmin.check(model=Song)
 
381
        self.assertEqual(errors, [])
 
382
 
 
383
    def test_readonly_on_method(self):
 
384
        def my_function(obj):
 
385
            pass
 
386
 
 
387
        class SongAdmin(admin.ModelAdmin):
 
388
            readonly_fields = (my_function,)
 
389
 
 
390
        errors = SongAdmin.check(model=Song)
 
391
        self.assertEqual(errors, [])
 
392
 
 
393
    def test_readonly_on_modeladmin(self):
 
394
        class SongAdmin(admin.ModelAdmin):
 
395
            readonly_fields = ("readonly_method_on_modeladmin",)
 
396
 
 
397
            def readonly_method_on_modeladmin(self, obj):
 
398
                pass
 
399
 
 
400
        errors = SongAdmin.check(model=Song)
 
401
        self.assertEqual(errors, [])
 
402
 
 
403
    def test_readonly_method_on_model(self):
 
404
        class SongAdmin(admin.ModelAdmin):
 
405
            readonly_fields = ("readonly_method_on_model",)
 
406
 
 
407
        errors = SongAdmin.check(model=Song)
 
408
        self.assertEqual(errors, [])
 
409
 
 
410
    def test_nonexistant_field(self):
 
411
        class SongAdmin(admin.ModelAdmin):
 
412
            readonly_fields = ("title", "nonexistent")
 
413
 
 
414
        errors = SongAdmin.check(model=Song)
 
415
        expected = [
 
416
            checks.Error(
 
417
                ("The value of 'readonly_fields[1]' is not a callable, an attribute "
 
418
                 "of 'SongAdmin', or an attribute of 'admin_checks.Song'."),
 
419
                hint=None,
 
420
                obj=SongAdmin,
 
421
                id='admin.E035',
 
422
            )
 
423
        ]
 
424
        self.assertEqual(errors, expected)
 
425
 
 
426
    def test_nonexistant_field_on_inline(self):
 
427
        class CityInline(admin.TabularInline):
 
428
            model = City
 
429
            readonly_fields = ['i_dont_exist']  # Missing attribute
 
430
 
 
431
        errors = CityInline.check(State)
 
432
        expected = [
 
433
            checks.Error(
 
434
                ("The value of 'readonly_fields[0]' is not a callable, an attribute "
 
435
                 "of 'CityInline', or an attribute of 'admin_checks.City'."),
 
436
                hint=None,
 
437
                obj=CityInline,
 
438
                id='admin.E035',
 
439
            )
 
440
        ]
 
441
        self.assertEqual(errors, expected)
 
442
 
 
443
    def test_extra(self):
 
444
        class SongAdmin(admin.ModelAdmin):
 
445
            def awesome_song(self, instance):
 
446
                if instance.title == "Born to Run":
 
447
                    return "Best Ever!"
 
448
                return "Status unknown."
 
449
 
 
450
        errors = SongAdmin.check(model=Song)
 
451
        self.assertEqual(errors, [])
 
452
 
 
453
    def test_readonly_lambda(self):
 
454
        class SongAdmin(admin.ModelAdmin):
 
455
            readonly_fields = (lambda obj: "test",)
 
456
 
 
457
        errors = SongAdmin.check(model=Song)
 
458
        self.assertEqual(errors, [])
 
459
 
 
460
    def test_graceful_m2m_fail(self):
 
461
        """
 
462
        Regression test for #12203/#12237 - Fail more gracefully when a M2M field that
 
463
        specifies the 'through' option is included in the 'fields' or the 'fieldsets'
 
464
        ModelAdmin options.
 
465
        """
 
466
 
 
467
        class BookAdmin(admin.ModelAdmin):
 
468
            fields = ['authors']
 
469
 
 
470
        errors = BookAdmin.check(model=Book)
 
471
        expected = [
 
472
            checks.Error(
 
473
                ("The value of 'fields' cannot include the ManyToManyField 'authors', "
 
474
                 "because that field manually specifies a relationship model."),
 
475
                hint=None,
 
476
                obj=BookAdmin,
 
477
                id='admin.E013',
 
478
            )
 
479
        ]
 
480
        self.assertEqual(errors, expected)
 
481
 
 
482
    def test_cannot_include_through(self):
 
483
        class FieldsetBookAdmin(admin.ModelAdmin):
 
484
            fieldsets = (
 
485
                ('Header 1', {'fields': ('name',)}),
 
486
                ('Header 2', {'fields': ('authors',)}),
 
487
            )
 
488
 
 
489
        errors = FieldsetBookAdmin.check(model=Book)
 
490
        expected = [
 
491
            checks.Error(
 
492
                ("The value of 'fieldsets[1][1][\"fields\"]' cannot include the ManyToManyField "
 
493
                 "'authors', because that field manually specifies a relationship model."),
 
494
                hint=None,
 
495
                obj=FieldsetBookAdmin,
 
496
                id='admin.E013',
 
497
            )
 
498
        ]
 
499
        self.assertEqual(errors, expected)
 
500
 
 
501
    def test_nested_fields(self):
 
502
        class NestedFieldsAdmin(admin.ModelAdmin):
 
503
            fields = ('price', ('name', 'subtitle'))
 
504
 
 
505
        errors = NestedFieldsAdmin.check(model=Book)
 
506
        self.assertEqual(errors, [])
 
507
 
 
508
    def test_nested_fieldsets(self):
 
509
        class NestedFieldsetAdmin(admin.ModelAdmin):
 
510
            fieldsets = (
 
511
                ('Main', {'fields': ('price', ('name', 'subtitle'))}),
 
512
            )
 
513
 
 
514
        errors = NestedFieldsetAdmin.check(model=Book)
 
515
        self.assertEqual(errors, [])
 
516
 
 
517
    def test_explicit_through_override(self):
 
518
        """
 
519
        Regression test for #12209 -- If the explicitly provided through model
 
520
        is specified as a string, the admin should still be able use
 
521
        Model.m2m_field.through
 
522
        """
 
523
 
 
524
        class AuthorsInline(admin.TabularInline):
 
525
            model = Book.authors.through
 
526
 
 
527
        class BookAdmin(admin.ModelAdmin):
 
528
            inlines = [AuthorsInline]
 
529
 
 
530
        errors = BookAdmin.check(model=Book)
 
531
        self.assertEqual(errors, [])
 
532
 
 
533
    def test_non_model_fields(self):
 
534
        """
 
535
        Regression for ensuring ModelAdmin.fields can contain non-model fields
 
536
        that broke with r11737
 
537
        """
 
538
 
 
539
        class SongForm(forms.ModelForm):
 
540
            extra_data = forms.CharField()
 
541
 
 
542
        class FieldsOnFormOnlyAdmin(admin.ModelAdmin):
 
543
            form = SongForm
 
544
            fields = ['title', 'extra_data']
 
545
 
 
546
        errors = FieldsOnFormOnlyAdmin.check(model=Song)
 
547
        self.assertEqual(errors, [])
 
548
 
 
549
    def test_non_model_first_field(self):
 
550
        """
 
551
        Regression for ensuring ModelAdmin.field can handle first elem being a
 
552
        non-model field (test fix for UnboundLocalError introduced with r16225).
 
553
        """
 
554
 
 
555
        class SongForm(forms.ModelForm):
 
556
            extra_data = forms.CharField()
 
557
 
 
558
            class Meta:
 
559
                model = Song
 
560
                fields = '__all__'
 
561
 
 
562
        class FieldsOnFormOnlyAdmin(admin.ModelAdmin):
 
563
            form = SongForm
 
564
            fields = ['extra_data', 'title']
 
565
 
 
566
        errors = FieldsOnFormOnlyAdmin.check(model=Song)
 
567
        self.assertEqual(errors, [])
 
568
 
 
569
    def test_validator_compatibility(self):
 
570
        class MyValidator(object):
 
571
            def validate(self, cls, model):
 
572
                raise ImproperlyConfigured("error!")
 
573
 
 
574
        class MyModelAdmin(admin.ModelAdmin):
 
575
            validator_class = MyValidator
 
576
 
 
577
        with warnings.catch_warnings(record=True):
 
578
            warnings.filterwarnings('ignore', module='django.contrib.admin.options')
 
579
            errors = MyModelAdmin.check(model=Song)
 
580
 
 
581
            expected = [
 
582
                checks.Error(
 
583
                    'error!',
 
584
                    hint=None,
 
585
                    obj=MyModelAdmin,
 
586
                )
 
587
            ]
 
588
            self.assertEqual(errors, expected)
 
589
 
 
590
    def test_check_sublists_for_duplicates(self):
 
591
        class MyModelAdmin(admin.ModelAdmin):
 
592
            fields = ['state', ['state']]
 
593
 
 
594
        errors = MyModelAdmin.check(model=Song)
 
595
        expected = [
 
596
            checks.Error(
 
597
                "The value of 'fields' contains duplicate field(s).",
 
598
                hint=None,
 
599
                obj=MyModelAdmin,
 
600
                id='admin.E006'
 
601
            )
 
602
        ]
 
603
        self.assertEqual(errors, expected)
 
604
 
 
605
    def test_check_fieldset_sublists_for_duplicates(self):
 
606
        class MyModelAdmin(admin.ModelAdmin):
 
607
            fieldsets = [
 
608
                (None, {
 
609
                    'fields': ['title', 'album', ('title', 'album')]
 
610
                }),
 
611
            ]
 
612
 
 
613
        errors = MyModelAdmin.check(model=Song)
 
614
        expected = [
 
615
            checks.Error(
 
616
                "There are duplicate field(s) in 'fieldsets[0][1]'.",
 
617
                hint=None,
 
618
                obj=MyModelAdmin,
 
619
                id='admin.E012'
 
620
            )
 
621
        ]
 
622
        self.assertEqual(errors, expected)