예제 #1
0
    def test_remove_trailing_name_in_headers(self):
        headers = ['heheName', 'somethingCode', 'hahaName', 'blablaCode', 'hihihi', 'hohoho']

        self.assertEqual(['hehe','somethingCode', 'haha', 'blablaCode', 'hihihi', 'hohoho'],
                         UploadService.remove_trailing('Name', in_array=headers))

        self.assertEqual(['hehe', 'haha', 'hihihi', 'hohoho'],
                         UploadService.remove_trailing('Name', in_array=headers, exclude='Code'))

        self.assertEqual(['hehe', 'haha', 'hihihi', 'hohoho'],
                         UploadService.remove_trailing('Name', headers, 'Code'))
예제 #2
0
 def clean_headers_location_type_order(self, headers):
     headers = UploadService.remove_trailing('Name', in_array=headers, exclude='Code')
     headers = [header.upper() for header in headers]
     if headers[0] == 'COUNTRY':
         headers.pop(0)
     location_types = [loc.name.upper() for loc in LocationType.all().exclude(name__iexact='COUNTRY')]
     if not location_types == headers:
         raise ValidationError('Location types not in order. Please refer to input file format.')
예제 #3
0
    def test_remove_trailing_name_in_headers(self):
        headers = [
            'heheName', 'somethingCode', 'hahaName', 'blablaCode', 'hihihi',
            'hohoho'
        ]

        self.assertEqual([
            'hehe', 'somethingCode', 'haha', 'blablaCode', 'hihihi', 'hohoho'
        ], UploadService.remove_trailing('Name', in_array=headers))

        self.assertEqual(['hehe', 'haha', 'hihihi', 'hohoho'],
                         UploadService.remove_trailing('Name',
                                                       in_array=headers,
                                                       exclude='Code'))

        self.assertEqual(['hehe', 'haha', 'hihihi', 'hohoho'],
                         UploadService.remove_trailing('Name', headers,
                                                       'Code'))
예제 #4
0
 def clean_headers_location_type_order(self, headers):
     headers = UploadService.remove_trailing('Name',
                                             in_array=headers,
                                             exclude='Code')
     ordered_types = [
         type.name
         for type in LocationTypeDetails.get_ordered_types().exclude(
             name__iexact='country')
     ]
     if not ordered_types == headers:
         raise ValidationError(
             'Location types not in order. Please refer to input file format.'
         )
예제 #5
0
 def clean_headers_location_type_order(self, headers):
     headers = UploadService.remove_trailing('Name',
                                             in_array=headers,
                                             exclude='Code')
     headers = [header.upper() for header in headers]
     if headers[0] == 'COUNTRY':
         headers.pop(0)
     location_types = [
         loc.name.upper()
         for loc in LocationType.all().exclude(name__iexact='COUNTRY')
     ]
     if not location_types == headers:
         raise ValidationError(
             'Location types not in order. Please refer to input file format.'
         )
예제 #6
0
 def clean_headers_location_type_order(self, headers):
     headers = UploadService.remove_trailing('Name', in_array=headers, exclude='Code')
     ordered_types = [type.name for type in LocationTypeDetails.get_ordered_types().exclude(name__iexact='country')]
     if not ordered_types == headers:
         raise ValidationError('Location types not in order. Please refer to input file format.')