def test_data_splits(self): """ Ensure the file is split up into files of max_lines. """ from karld.loadump import split_file split_file(self.input_data_path, self.out_dir, max_lines=5) self.assertTrue(os.path.exists(self.expected_out_0)) self.assertTrue(os.path.exists(self.expected_out_1)) with open(self.expected_out_0, 'rb') as stream: data = stream.read() self.assertEqual(b'mushroom,fungus\ntomato,fruit\ntopaz,mineral\n' b'iron,metal\ndr\xc3\xb3\xc5\xbck\xc4\x85,' b'utf-8 sample\n', data)
def test_default_out_dir(self): """ Ensure default output directory is the same as the directory of the input file """ from karld.loadump import split_file expected_outdir_dir = os.path.dirname(self.input_data_path) expected_out_0 = os.path.join(expected_outdir_dir, "0_data_0.csv") if os.path.exists(expected_out_0): os.remove(expected_out_0) split_file(self.input_data_path, max_lines=100) self.assertTrue(os.path.exists(expected_out_0)) if os.path.exists(expected_out_0): os.remove(expected_out_0)