def test_command_id(self, capsys, volume_ids, volume_paths):
     ''' Test the command line tool for one id'''
     parser = utils._htid2rsync_argparser()
     for i, volume_id in enumerate(volume_ids):
         utils._htid2rsync_parse_args(parser, [volume_id])
         # Catch what was written to stdout
         out, err = capsys.readouterr()
         assert out.strip() == volume_paths[i]
Beispiel #2
0
 def test_command_id(self, capsys, volume_ids, volume_paths):
     ''' Test the command line tool for one id'''
     parser = utils._htid2rsync_argparser()
     for i, volume_id in enumerate(volume_ids):
         utils._htid2rsync_parse_args(parser, [volume_id])
         # Catch what was written to stdout
         out, err = capsys.readouterr()
         assert out.strip() == volume_paths[i]
Beispiel #3
0
    def test_command_id(self, capsys, volume_ids, stubbytree_volume_paths,
                        pairtree_volume_paths):
        ''' Test the command line tool for one id'''
        parser = utils._htid2rsync_argparser()
        for i, volume_id in enumerate(volume_ids):
            utils._htid2rsync_parse_args(parser, [volume_id])
            out, err = capsys.readouterr()
            assert out.strip() == stubbytree_volume_paths[i]

            utils._htid2rsync_parse_args(parser, ['--oldstyle', volume_id])
            out, err = capsys.readouterr()
            assert out.strip() == pairtree_volume_paths[i]
Beispiel #4
0
    def test_command_ids(self, capsys, volume_ids, stubbytree_volume_paths,
                         pairtree_volume_paths):
        ''' Test the command line tool for multiple ids'''
        parser = utils._htid2rsync_argparser()

        utils._htid2rsync_parse_args(parser, volume_ids)
        out, err = capsys.readouterr()
        assert out.strip().split("\n") == stubbytree_volume_paths

        # Test oldstyle pairtree
        utils._htid2rsync_parse_args(parser, ['--oldstyle'] + volume_ids)
        out, err = capsys.readouterr()
        assert out.strip().split("\n") == pairtree_volume_paths
Beispiel #5
0
    def test_command_infile(self, tmpdir, capsys, volume_ids,
                            stubbytree_volume_paths):
        ''' Test the command line tool with an input file'''
        # Write input file for testing
        idfile = os.path.join(str(tmpdir), "idfile.txt")

        with open(idfile, "w") as f:
            f.write("\n".join(volume_ids))

        parser = utils._htid2rsync_argparser()

        # Assert proper functionality
        utils._htid2rsync_parse_args(parser, ["--from-file", idfile])
        out, err = capsys.readouterr()
        assert out.strip().split("\n") == stubbytree_volume_paths

        # Short arg
        utils._htid2rsync_parse_args(parser, ["--f", idfile])
        out2, err2 = capsys.readouterr()
        assert out == out2

        # Assert error when grouping cmd args and file
        with pytest.raises(SystemExit):
            utils._htid2rsync_parse_args(parser,
                                         ["--from-file", idfile] + volume_ids)

        # Assert error when grouping cmd args and file
        with pytest.raises(SystemExit):
            utils._htid2rsync_parse_args(parser, ["-f", idfile] + volume_ids)
Beispiel #6
0
 def test_command_infile(self, tmpdir, capsys, volume_ids, volume_paths):
     ''' Test the command line tool with an input file'''
     # Write input file for testing
     idfile = os.path.join(str(tmpdir), "idfile.txt")
     
     with open(idfile, "w") as f:
         f.write("\n".join(volume_ids))
     
     parser = utils._htid2rsync_argparser()
     
     # Assert proper functionality
     utils._htid2rsync_parse_args(parser, ["--from-file", idfile])
     out, err = capsys.readouterr()
     assert out.strip().split("\n") == volume_paths
     
     # Short arg
     utils._htid2rsync_parse_args(parser, ["--f", idfile])
     out2, err2 = capsys.readouterr()
     assert out == out2
     
     # Assert error when grouping cmd args and file
     with pytest.raises(SystemExit):
         utils._htid2rsync_parse_args(parser, ["--from-file", idfile] + volume_ids)
         
     # Assert error when grouping cmd args and file
     with pytest.raises(SystemExit):
         utils._htid2rsync_parse_args(parser, ["-f", idfile] + volume_ids)
Beispiel #7
0
    def test_command_outfile(self, tmpdir, volume_ids, volume_paths):
        ''' Test the command line tool with an output file'''
        # Output volume paths to file with outfile
        parser = utils._htid2rsync_argparser()
        outfile = os.path.join(str(tmpdir), "volumepaths.txt")
        utils._htid2rsync_parse_args(parser, ["--outfile", outfile] + volume_ids)
        
        # Save with short arg
        utils._htid2rsync_parse_args(parser, ["-o", outfile + ".short"] + volume_ids)
        
        # Re-open
        with open(outfile) as f:
            assert f.read().strip().split("\n") == volume_paths

        with open(outfile + ".short") as f:
            assert f.read().strip().split("\n") == volume_paths
    def test_command_outfile(self, tmpdir, volume_ids, volume_paths):
        ''' Test the command line tool with an output file'''
        # Output volume paths to file with outfile
        parser = utils._htid2rsync_argparser()
        outfile = os.path.join(str(tmpdir), "volumepaths.txt")
        utils._htid2rsync_parse_args(parser,
                                     ["--outfile", outfile] + volume_ids)

        # Save with short arg
        utils._htid2rsync_parse_args(parser,
                                     ["-o", outfile + ".short"] + volume_ids)

        # Re-open
        with open(outfile) as f:
            assert f.read().strip().split("\n") == volume_paths

        with open(outfile + ".short") as f:
            assert f.read().strip().split("\n") == volume_paths
 def test_command_ids(self, capsys, volume_ids, volume_paths):
     ''' Test the command line tool for multiple ids'''
     parser = utils._htid2rsync_argparser()
     utils._htid2rsync_parse_args(parser, volume_ids)
     out, err = capsys.readouterr()
     assert out.strip().split("\n") == volume_paths
Beispiel #10
0
 def test_command_ids(self, capsys, volume_ids, volume_paths):
     ''' Test the command line tool for multiple ids'''
     parser = utils._htid2rsync_argparser()
     utils._htid2rsync_parse_args(parser, volume_ids)
     out, err = capsys.readouterr()
     assert out.strip().split("\n") == volume_paths