def test_duplicate_detection(self): # Section "4. Row and Column Editing, # Duplicate Row Detection and Deletion" # {7}, {8} response = self.project.get_rows(sort_by='email') indexes = [row.index for row in response.rows] self.assertEqual(indexes, [4, 9, 8, 3, 0, 2, 5, 6, 1, 7]) # {9} self.project.reorder_rows() self.assertInResponse('Reorder rows') response = self.project.get_rows() indexes = [row.index for row in response.rows] self.assertEqual(indexes, range(10)) # {10} self.project.add_column( 'email', 'count', 'facetCount(value, "value", "email")') self.assertInResponse('column email by filling 10 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 counts = [row['count'] for row in response.rows] self.assertEqual(counts, [2, 2, 1, 1, 3, 3, 3, 1, 2, 2]) # {11} self.assertFalse(self.project.has_records) self.project.blank_down('email') self.assertInResponse('Blank down 4 cells') self.assertTrue(self.project.has_records) response = self.project.get_rows() emails = [1 if row['email'] else 0 for row in response.rows] self.assertEqual(emails, [1, 0, 1, 1, 1, 0, 0, 1, 1, 0]) # {12} blank_facet = facet.BlankFacet('email', selection=True) # {13} self.project.remove_rows(blank_facet) self.assertInResponse('Remove 4 rows') self.project.engine.remove_all() response = self.project.get_rows() email_counts = [(row['email'], row['count']) for row in response.rows] self.assertEqual(email_counts, [ (u'*****@*****.**', 2), (u'*****@*****.**', 1), (u'*****@*****.**', 1), (u'*****@*****.**', 3), (u'*****@*****.**', 1), (u'*****@*****.**', 2) ])
def test_transpose_variable_number_of_rows_into_columns(self): # {20}, {21} self.project.add_column('Column', 'First Line', 'if(value.contains(" on "), value, null)') self.assertInResponse('Column by filling 4 rows') response = self.project.get_rows() first_names = [ row['First Line'][0:10] if row['First Line'] else None for row in response.rows ] self.assertEqual(first_names, [ 'Tom Dalton', None, None, None, 'Morgan Law', None, None, None, None, 'Eric Batem' ]) # {22} self.project.move_column('First Line', 0) self.assertInResponse('Move column First Line to position 0') self.assertEqual(self.project.column_order['First Line'], 0) # {23} self.project.engine.mode = 'record-based' response = self.project.get_rows() self.assertEqual(response.mode, 'record-based') self.assertEqual(response.filtered, 4) # {24} self.project.add_column('Column', 'Status', 'row.record.cells["Column"].value[-1]') self.assertInResponse('filling 18 rows') # {25} self.project.text_transform( 'Column', 'row.record.cells["Column"].value[1, -1].join("|")') self.assertInResponse('18 cells') # {26} self.project.engine.mode = 'row-based' # {27} blank_facet = facet.BlankFacet('First Line', selection=True) self.project.remove_rows(blank_facet) self.assertInResponse('Remove 14 rows') self.project.engine.remove_all() # {28} self.project.split_column('Column', separator='|') self.assertInResponse('Split 4 cell(s) in column Column')