Ver Fonte

HUE-8737 [dashboard] Avoid TypeError: '<' not supported between instances of 'dict' and 'dict'

Romain há 6 anos atrás
pai
commit
1c7a5573f9

+ 5 - 4
apps/search/src/search/tests.py

@@ -442,6 +442,7 @@ class TestWithMockedSolr(TestSearchBase):
          {'isDynamic': False, 'isId': None, 'type': 'string', 'name': 'content_type'},
          {'isDynamic': False, 'isId': None, 'type': 'text_general', 'name': 'description'},
          {'isDynamic': False, 'isId': None, 'type': 'text_general', 'name': 'features'},
+         {'isDynamic': False, 'isId': True, 'type': 'string', 'name': 'id'}
          {'isDynamic': False, 'isId': None, 'type': 'boolean', 'name': 'inStock'},
          {'isDynamic': False, 'isId': None, 'type': 'text_general', 'name': 'includes'},
          {'isDynamic': False, 'isId': None, 'type': 'text_general', 'name': 'keywords'},
@@ -462,8 +463,8 @@ class TestWithMockedSolr(TestSearchBase):
          {'isDynamic': False, 'isId': None, 'type': 'text_general', 'name': 'title'},
          {'isDynamic': False, 'isId': None, 'type': 'text_general', 'name': 'url'},
          {'isDynamic': False, 'isId': None, 'type': 'float', 'name': 'weight'},
-         {'isDynamic': False, 'isId': True, 'type': 'string', 'name': 'id'}],
-         self.collection.fields_data(self.user, 'collection_1')
+        ],
+        self.collection.fields_data(self.user, 'collection_1')
     )
 
   # TODO
@@ -493,9 +494,9 @@ class TestWithMockedSolr(TestSearchBase):
     assert_equal('application/csv', csv_response['Content-Type'])
     assert_equal('attachment; filename="query_result.csv"', csv_response['Content-Disposition'])
     assert_equal(4 + 1 + 1, len(csv_response_content.split('\n')), csv_response_content.split('\n'))
-    assert_true('&lt;script&gt;alert(1234)&lt;/script&gt;,_version_,author,category,comments,content,content_type,description,features,inStock,includes,keywords,last_modified,links,manu,manu_exact,name,payloads,popularity,price,resourcename,sku,store,subject,text,text_rev,title,url,weight,id' in csv_response_content, csv_response_content)
+    assert_true('&lt;script&gt;alert(1234)&lt;/script&gt;,_version_,author,category,comments,content,content_type,description,features,id,inStock,includes,keywords,last_modified,links,manu,manu_exact,name,payloads,popularity,price,resourcename,sku,store,subject,text,text_rev,title,url,weight' in csv_response_content, csv_response_content)
     # Fields does not exactly match the response but this is because the collection schema does not match the query response.
-    assert_true(""",1450807641462800385,"['B B Hallberg', 'M M Blennow']",,,,,,,,,,,,,,,,,,,,,,,,,,,23680099""" in csv_response_content, csv_response_content)
+    assert_true(""",1450807641462800385,"['B B Hallberg', 'M M Blennow']",,,,,,,23680099,,,,,,,,,,,,,,,,,,,,""" in csv_response_content, csv_response_content)
 
     xls_response = self.c.post(reverse('search:download'), {
         'type': 'xls',

+ 1 - 1
desktop/libs/dashboard/src/dashboard/models.py

@@ -291,7 +291,7 @@ class Collection2(object):
         LOG.error('Could not access collection: %s' % e)
         return []
 
-    return sorted([self._make_field(field, attributes) for field, attributes in schema_fields.items()])
+    return sorted([self._make_field(field, attributes) for field, attributes in schema_fields.items()], key=lambda f: f['name'])
 
   def update_data(self, post_data):
     data_dict = self.data

+ 5 - 4
desktop/libs/dashboard/src/dashboard/tests.py

@@ -445,6 +445,7 @@ class TestWithMockedSolr(TestSearchBase):
          {'isDynamic': False, 'isId': None, 'type': 'string', 'name': 'content_type'},
          {'isDynamic': False, 'isId': None, 'type': 'text_general', 'name': 'description'},
          {'isDynamic': False, 'isId': None, 'type': 'text_general', 'name': 'features'},
+         {'isDynamic': False, 'isId': True, 'type': 'string', 'name': 'id'},
          {'isDynamic': False, 'isId': None, 'type': 'boolean', 'name': 'inStock'},
          {'isDynamic': False, 'isId': None, 'type': 'text_general', 'name': 'includes'},
          {'isDynamic': False, 'isId': None, 'type': 'text_general', 'name': 'keywords'},
@@ -465,8 +466,8 @@ class TestWithMockedSolr(TestSearchBase):
          {'isDynamic': False, 'isId': None, 'type': 'text_general', 'name': 'title'},
          {'isDynamic': False, 'isId': None, 'type': 'text_general', 'name': 'url'},
          {'isDynamic': False, 'isId': None, 'type': 'float', 'name': 'weight'},
-         {'isDynamic': False, 'isId': True, 'type': 'string', 'name': 'id'}],
-         self.collection.fields_data(self.user, 'collection_1')
+         ],
+        self.collection.fields_data(self.user, 'collection_1')
     )
 
   # TODO
@@ -496,9 +497,9 @@ class TestWithMockedSolr(TestSearchBase):
     assert_equal('application/csv', csv_response['Content-Type'])
     assert_equal('attachment; filename="query_result.csv"', csv_response['Content-Disposition'])
     assert_equal(4 + 1 + 1, len(csv_response_content.split('\n')), csv_response_content.split('\n'))
-    assert_true('&lt;script&gt;alert(1234)&lt;/script&gt;,_version_,author,category,comments,content,content_type,description,features,inStock,includes,keywords,last_modified,links,manu,manu_exact,name,payloads,popularity,price,resourcename,sku,store,subject,text,text_rev,title,url,weight,id' in csv_response_content, csv_response_content)
+    assert_true('&lt;script&gt;alert(1234)&lt;/script&gt;,_version_,author,category,comments,content,content_type,description,features,id,inStock,includes,keywords,last_modified,links,manu,manu_exact,name,payloads,popularity,price,resourcename,sku,store,subject,text,text_rev,title,url,weight' in csv_response_content, csv_response_content)
     # Fields does not exactly match the response but this is because the collection schema does not match the query response.
-    assert_true(""",1450807641462800385,"['B B Hallberg', 'M M Blennow']",,,,,,,,,,,,,,,,,,,,,,,,,,,23680099""" in csv_response_content, csv_response_content)
+    assert_true(""",1450807641462800385,"['B B Hallberg', 'M M Blennow']",,,,,,,23680099,,,,,,,,,,,,,,,,,,,,""" in csv_response_content, csv_response_content)
 
     xls_response = self.c.post(reverse('dashboard:download'), {
         'type': 'xls',