def testImportCitiesFromCSVFile(self): rows = [ ['City', 'Region', 'Country'], ['Toronto', 'Ontario', 'Canada'], ] csvfile = [','.join(row) for row in rows] City.import_from_csv(csvfile) city = list(City.query())[0] self.assertEqual(city.name, 'Toronto') self.assertEqual(city.region, 'Ontario') self.assertEqual(city.country, 'Canada')
def form_valid(self): lines = self.form['file'].splitlines() City.import_from_csv(lines)