Exemplo n.º 1
0
 def test_roundtrip_stdout(self, input_file, good_path, capsys):
     mf.main([
         'extract', '--index_column=id_number', '--skip=1', good_path,
         input_file, '-'
     ])
     out, _err = capsys.readouterr()
     lines = out.split('\r\n')
     assert len(lines) == 11
     assert lines[-1] == ''
     columns = lines[0].split(',')
     assert columns[0] == 'ppt_id'
Exemplo n.º 2
0
 def test_roundtrip_file(self, input_file, good_path, tmpdir):
     outfile = str(tmpdir.join('output.csv'))
     mf.main([
         'extract', '--index_column=id_number', '--skip=1', good_path,
         input_file, outfile
     ])
     out = open(outfile, newline=LINE_ENDING).read()
     lines = out.split(LINE_ENDING)
     assert len(lines) == 11
     assert lines[-1].strip() == ''
     columns = lines[0].split(',')
     assert columns[0] == 'ppt_id'
Exemplo n.º 3
0
 def test_retval_nonzero_for_good_with_problem_files(
         self, good_path, problems_path, capsys):
     problem_file = glob.glob(path.join(problems_path, '*csv'))[0]
     retval = mf.main(['validate', good_path, problem_file])
     out, _err = capsys.readouterr()
     assert not retval == 0
     assert len(out) > 0
     assert 'problems' in out
Exemplo n.º 4
0
 def test_retval_nonzero_for_problems_dir(self, problems_path, capsys):
     retval = mf.main(['validate', problems_path])
     out, _err = capsys.readouterr()
     assert not retval == 0
     assert len(out) > 0
     assert 'problems' in out
Exemplo n.º 5
0
 def test_retval_nonzero_for_bad_dir(self, example_path, capsys):
     retval = mf.main(['validate', example_path])
     out, _err = capsys.readouterr()
     assert not retval == 0
     assert len(out) > 0
Exemplo n.º 6
0
 def test_retval_zero_for_good_dir(self, good_path, capsys):
     retval = mf.main(['validate', good_path])
     out, err = capsys.readouterr()
     assert out.startswith('No problems found')
     assert err == ''
     assert retval == 0
 def test_prints_output_on_success_outfile(self, good_path, tmpdir):
     outfile = str(tmpdir.join('dict.csv'))
     mf.main(['create', good_path, outfile])
     assert path.exists(str(outfile))
     assert path.getsize(str(outfile)) > 0
 def test_prints_output_on_success_stdout(self, good_path, capsys):
     mf.main(['create', good_path, '-'])
     out, err = capsys.readouterr()
     assert len(out) > 0