def test_new_rows_with_headings(self): """Test a simple creating a CouchGrid """ #create a test widget with test database values cw = CouchGrid(self.dbname) #allow editing cw.editable = True #create headers/keys cw.keys = ["Key1", "Key2", "Key3", "Key4"] #set the record_type for the TreeView #it will not populate without this value being set cw.record_type = self.record_type #create a row with all four columns set cw.append_row({ "Key1": "val1", "Key2": "val2", "Key2": "val3", "Key4": "val4" }) #create a row with only the second column set cw.append_row({"Key1": "", "Key2": "val2"}) #create an empty row (which will not be saved until the user edits it) cw.append_row({}) #if this all worked, there should be three rows in the model model = cw.get_model() self.assertEqual(len(model), 3)
def test_single_col_from_database(self): #create some records self.db.put_record( Record({ "key1_1": "val1_1", "key1_2": "val1_2", "key1_3": "val1_3", "record_type": self.record_type })) self.db.put_record( Record({ "key1_1": "val2_1", "key1_2": "val2_2", "key1_3": "val2_3", "record_type": self.record_type })) #build the CouchGrid cw = CouchGrid(self.dbname) cw.keys = ["key1_1"] cw.record_type = self.record_type #make sure there are three columns and two rows self.assertEqual(cw.get_model().get_n_columns(), 2) self.assertEqual(len(cw.get_model()), 2)