Add blank_down() and project.has_records (its consequence). Fix unintentional sort in test, and clear sort after reorder_rows().
This commit is contained in:
parent
d3b4a38574
commit
062f283e6b
|
@ -395,6 +395,7 @@ class RefineProject:
|
||||||
self.engine = Engine()
|
self.engine = Engine()
|
||||||
self.sorting = Sorting()
|
self.sorting = Sorting()
|
||||||
# following filled in by get_models()
|
# following filled in by get_models()
|
||||||
|
self.has_records = False
|
||||||
self.column_order = {} # order of column in UI
|
self.column_order = {} # order of column in UI
|
||||||
self.rows_response_factory = None # for parsing get_rows()
|
self.rows_response_factory = None # for parsing get_rows()
|
||||||
self.get_models()
|
self.get_models()
|
||||||
|
@ -426,6 +427,7 @@ class RefineProject:
|
||||||
self.column_order[name] = i
|
self.column_order[name] = i
|
||||||
column_index[name] = column['cellIndex']
|
column_index[name] = column['cellIndex']
|
||||||
self.key_column = column_model['keyColumnName']
|
self.key_column = column_model['keyColumnName']
|
||||||
|
self.has_records = response['recordModel'].get('hasRecords', False)
|
||||||
self.rows_response_factory = RowsResponseFactory(column_index)
|
self.rows_response_factory = RowsResponseFactory(column_index)
|
||||||
# TODO: implement rest
|
# TODO: implement rest
|
||||||
return response
|
return response
|
||||||
|
@ -480,6 +482,8 @@ class RefineProject:
|
||||||
self.sorting = Sorting(sort_by)
|
self.sorting = Sorting(sort_by)
|
||||||
response = self.do_json('reorder-rows',
|
response = self.do_json('reorder-rows',
|
||||||
{'sorting': self.sorting.as_json()})
|
{'sorting': self.sorting.as_json()})
|
||||||
|
# clear sorting
|
||||||
|
self.sorting = Sorting()
|
||||||
return response
|
return response
|
||||||
|
|
||||||
def remove_rows(self, facets=None):
|
def remove_rows(self, facets=None):
|
||||||
|
@ -557,3 +561,8 @@ class RefineProject:
|
||||||
'columnInsertIndex': column_insert_index, 'onError': on_error})
|
'columnInsertIndex': column_insert_index, 'onError': on_error})
|
||||||
self.get_models()
|
self.get_models()
|
||||||
return response
|
return response
|
||||||
|
|
||||||
|
def blank_down(self, column):
|
||||||
|
response = self.do_json('blank-down', {'columnName': column})
|
||||||
|
self.get_models()
|
||||||
|
return response
|
|
@ -275,7 +275,7 @@ class TutorialTestDuplicateDetection(RefineTestCase):
|
||||||
response = self.project.reorder_rows()
|
response = self.project.reorder_rows()
|
||||||
self.assertEqual('Reorder rows',
|
self.assertEqual('Reorder rows',
|
||||||
response['historyEntry']['description'])
|
response['historyEntry']['description'])
|
||||||
response = self.project.get_rows(sort_by='email')
|
response = self.project.get_rows()
|
||||||
indexes = [r.index for r in response.rows]
|
indexes = [r.index for r in response.rows]
|
||||||
self.assertEqual(indexes, range(10))
|
self.assertEqual(indexes, range(10))
|
||||||
# {10}
|
# {10}
|
||||||
|
@ -284,10 +284,19 @@ class TutorialTestDuplicateDetection(RefineTestCase):
|
||||||
self.assertTrue('column email by filling 10 rows' in
|
self.assertTrue('column email by filling 10 rows' in
|
||||||
response['historyEntry']['description'])
|
response['historyEntry']['description'])
|
||||||
response = self.project.get_rows()
|
response = self.project.get_rows()
|
||||||
|
self.assertEqual(self.project.column_order['email'], 0) # i.e. 1st
|
||||||
self.assertEqual(self.project.column_order['count'], 1) # i.e. 2nd
|
self.assertEqual(self.project.column_order['count'], 1) # i.e. 2nd
|
||||||
counts = [r['count'] for r in response.rows]
|
counts = [r['count'] for r in response.rows]
|
||||||
self.assertEqual(counts, [2, 2, 1, 1, 3, 3, 3, 1, 2, 2])
|
self.assertEqual(counts, [2, 2, 1, 1, 3, 3, 3, 1, 2, 2])
|
||||||
|
# {11}
|
||||||
|
self.assertFalse(self.project.has_records)
|
||||||
|
response = self.project.blank_down('email')
|
||||||
|
self.assertTrue('Blank down 4 cells' in
|
||||||
|
response['historyEntry']['description'])
|
||||||
|
self.assertTrue(self.project.has_records)
|
||||||
|
response = self.project.get_rows()
|
||||||
|
emails = [1 if r['email'] else 0 for r in response.rows]
|
||||||
|
self.assertEqual(emails, [1, 0, 1, 1, 1, 0, 0, 1, 1, 0])
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
unittest.main()
|
unittest.main()
|
Loading…
Reference in New Issue