diff options
| author | Étienne Loks <etienne.loks@iggdrasil.net> | 2018-05-21 17:24:01 +0200 | 
|---|---|---|
| committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2018-06-12 08:44:34 +0200 | 
| commit | 62764f77311c5969f62c44f516b652bbe81bae28 (patch) | |
| tree | 8c354f4e11e04abb4adbfed6f94c6efa6f42492f /ishtar_common/tests.py | |
| parent | ab1a29984cb388b193b249ddeac2e8c8e7c2c495 (diff) | |
| download | Ishtar-62764f77311c5969f62c44f516b652bbe81bae28.tar.bz2 Ishtar-62764f77311c5969f62c44f516b652bbe81bae28.zip | |
Tests - admin importers actions: importer type and coulmn duplicate. Column shift.
Diffstat (limited to 'ishtar_common/tests.py')
| -rw-r--r-- | ishtar_common/tests.py | 69 | 
1 files changed, 69 insertions, 0 deletions
| diff --git a/ishtar_common/tests.py b/ishtar_common/tests.py index 0d606476d..fe88cea51 100644 --- a/ishtar_common/tests.py +++ b/ishtar_common/tests.py @@ -608,6 +608,75 @@ class AdminGenTypeTest(TestCase):              finally:                  f.close() +    def test_importer_type_duplicate(self): +        model = models.ImporterType +        base_url = '/admin/{}/{}/'.format(self.module_name, +                                          model.__name__.lower()) +        ref = model.objects.all()[0] +        nb = model.objects.count() +        response = self.client.post( +            base_url, {'action': 'duplicate_importertype', +                       '_selected_action': [str(ref.pk)]}) +        self.assertEqual(response.status_code, 302) +        self.assertEqual(nb + 1, model.objects.count()) +        duplicate = model.objects.order_by('-pk').all()[0] +        self.assertEqual(duplicate.columns.count(), +                         ref.columns.count()) + +    def test_importer_column_duplicate(self): +        model = models.ImporterColumn +        base_url = '/admin/{}/{}/'.format(self.module_name, +                                          model.__name__.lower()) +        ref = model.objects.all()[0] +        nb = model.objects.count() +        response = self.client.post( +            base_url, {'action': 'duplicate_importercolumn', +                       '_selected_action': [str(ref.pk)]}) +        self.assertEqual(response.status_code, 302) +        self.assertEqual(nb + 1, model.objects.count()) +        duplicate = model.objects.order_by('-pk').all()[0] +        self.assertEqual(duplicate.duplicate_fields.count(), +                         ref.duplicate_fields.count()) +        self.assertEqual(duplicate.targets.count(), +                         ref.targets.count()) + +    def test_importer_column_shift(self): +        model = models.ImporterColumn +        importer_type = models.ImporterType.objects.get( +            slug='ishtar-operations') +        # col in fixture should be well ordered +        for idx, col in enumerate( +                importer_type.columns.order_by('col_number').all()): +            self.assertEqual(col.col_number, idx + 1) + +        base_url = '/admin/{}/{}/'.format(self.module_name, +                                          model.__name__.lower()) +        response = self.client.post( +            base_url, { +                'action': 'shift_right', +                '_selected_action': [ +                    str(c.pk) for c in importer_type.columns.all() +                ]}) +        self.assertEqual(response.status_code, 302) + +        # col shifted to the right +        for idx, col in enumerate( +                importer_type.columns.order_by('col_number').all()): +            self.assertEqual(col.col_number, idx + 2) + +        response = self.client.post( +            base_url, { +                'action': 'shift_left', +                '_selected_action': [ +                    str(c.pk) for c in importer_type.columns.all() +                ]}) +        self.assertEqual(response.status_code, 302) + +        # col shifted back to the left +        for idx, col in enumerate( +                importer_type.columns.order_by('col_number').all()): +            self.assertEqual(col.col_number, idx + 1) +      def test_str(self):          # test __str__          for model in self.models_with_data: | 
