def test_import(self): # TODO: create a test to check that we aren't using an insert # statement for import that assumes a column value from the previous # insert values, could probably create an insert statement from a # row in the test data and then create an insert statement from some # other dummy data that has different columns from the test data and # see if any of the columns from the second insert statement has values # from the first statement # TODO: this test doesn't really test yet that any of the data was # correctly imported or exported, only that export and importing # run successfuly # 1. write the test data to a temporary file or files # 2. import the data and make sure the objects match field for field # the exporters and importers show logging information, turn it off logging.getLogger('bauble.info').setLevel(logging.ERROR) import tempfile tempdir = tempfile.mkdtemp() # export all the testdata exporter = CSVExporter() exporter.start(tempdir) # import all the files in the temp directory filenames = os.listdir(tempdir) importer = CSVImporter() # import twice to check for regression Launchpad #??? importer.start([os.path.join(tempdir, name) for name in filenames], force=True) importer.start([os.path.join(tempdir, name) for name in filenames], force=True)
def test_export_none_is_empty(self): """ Test exporting a None column exports a '' """ species = Species(genus_id=1, sp='sp') from tempfile import mkdtemp temp_path = mkdtemp() exporter = CSVExporter() exporter.start(temp_path) f = open(os.path.join(temp_path, 'species.txt')) reader = csv.DictReader(f, dialect=csv.excel) row = reader.next() self.assert_(row['cv_group'] == '')
def test_export_none_is_empty(self): """ Test exporting a None column exports a '' """ species = Species(genus_id=1, sp='sp') self.assertTrue(species is not None) from tempfile import mkdtemp temp_path = mkdtemp() exporter = CSVExporter() exporter.start(temp_path) f = open(os.path.join(temp_path, 'species.txt')) reader = csv.DictReader(f, dialect=csv.excel) row = reader.next() self.assert_(row['cv_group'] == '')