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:
Paul Makepeace 2011-04-25 15:45:20 -04:00
parent d3b4a38574
commit 062f283e6b
2 changed files with 20 additions and 2 deletions

View File

@ -395,6 +395,7 @@ class RefineProject:
self.engine = Engine()
self.sorting = Sorting()
# following filled in by get_models()
self.has_records = False
self.column_order = {} # order of column in UI
self.rows_response_factory = None # for parsing get_rows()
self.get_models()
@ -426,6 +427,7 @@ class RefineProject:
self.column_order[name] = i
column_index[name] = column['cellIndex']
self.key_column = column_model['keyColumnName']
self.has_records = response['recordModel'].get('hasRecords', False)
self.rows_response_factory = RowsResponseFactory(column_index)
# TODO: implement rest
return response
@ -480,6 +482,8 @@ class RefineProject:
self.sorting = Sorting(sort_by)
response = self.do_json('reorder-rows',
{'sorting': self.sorting.as_json()})
# clear sorting
self.sorting = Sorting()
return response
def remove_rows(self, facets=None):
@ -557,3 +561,8 @@ class RefineProject:
'columnInsertIndex': column_insert_index, 'onError': on_error})
self.get_models()
return response
def blank_down(self, column):
response = self.do_json('blank-down', {'columnName': column})
self.get_models()
return response

View File

@ -275,7 +275,7 @@ class TutorialTestDuplicateDetection(RefineTestCase):
response = self.project.reorder_rows()
self.assertEqual('Reorder rows',
response['historyEntry']['description'])
response = self.project.get_rows(sort_by='email')
response = self.project.get_rows()
indexes = [r.index for r in response.rows]
self.assertEqual(indexes, range(10))
# {10}
@ -284,10 +284,19 @@ class TutorialTestDuplicateDetection(RefineTestCase):
self.assertTrue('column email by filling 10 rows' in
response['historyEntry']['description'])
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
counts = [r['count'] for r in response.rows]
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__':
unittest.main()