def organize_fields(self, fields): """Setup fields property.""" if fields == "all": fields = self.object_headers.keys() else: # There may be cases when `fields` (sent from FE) contains local CAs # but self.object_headers does not have them since there are no such # local CAs for objects being exported. fields = set(fields) & set(self.object_headers.keys()) self.fields = import_helper.get_column_order(fields)
def test_column_order(self): """Test sorting of colums by a predined positions. The predifined positions for all columns can be found in reflection.py. Attr_list is created in an expected correct order, against which a newly orderd list is compaired. """ attr_list = [ "slug", "title", "description", "notes", "test_plan", "owners", "start_date", "status", "kind", "name", "email", "is_enabled", "company", "documents_file", "documents_reference_url", "A Capital custom attribute", "a simple custom attribute", "some custom attribute", "map:A thing", "map:B thing", "map:c thing", "map:Program", "map:some other mapping", ] original_list = copy.copy(attr_list) for _ in range(10): random.shuffle(attr_list) column_order = import_helper.get_column_order(attr_list) self.assertEqual(original_list, column_order)
def test_column_order(self): """Test sorting of columns by a predefined positions. The predefined positions for all columns can be found in reflection.py. Attr_list is created in an expected correct order, against which a newly ordered list is compared. """ attr_list = [ "slug", "title", "description", "notes", "test_plan", "owners", "start_date", "status", "kind", "name", "email", "is_enabled", "company", "documents_file", "documents_reference_url", "A Capital custom attribute", "a simple custom attribute", "some custom attribute", "map:A thing", "map:B thing", "map:c thing", "map:Program", "map:some other mapping", ] original_list = copy.copy(attr_list) for _ in range(10): random.shuffle(attr_list) column_order = import_helper.get_column_order(attr_list) self.assertEqual(original_list, column_order)
def organize_fields(self, fields): """Setup fields property.""" if fields == "all": fields = self.object_headers.keys() self.fields = get_column_order(fields)
def organize_fields(self, fields): if fields == "all": fields = self.object_headers.keys() self.fields = get_column_order(fields)