示例#1
0
    def test_copy(self, capsys):
        commands.Projects().run('-s', 'copy_test_dst')
        out, err = capsys.readouterr()
        lines = out.split('\n')
        assert re.search(r".*Switched to project.*", lines[0])

        commands.Find().run('all')
        out, err = capsys.readouterr()
        assert out == ""

        commands.Projects().run('-s', 'copy_test_src')
        out, err = capsys.readouterr()
        lines = out.split('\n')
        assert re.search(r".*Switched to project.*", lines[0])

        commands.Find().run('all')
        out, err = capsys.readouterr()
        assert out == ""

        commands.Open().run(
            '-f', os.path.join(FIXTURE_DIR, "chromeinstall-8u31.exe"))
        commands.Store().run()
        out, err = capsys.readouterr()
        lines = out.split('\n')
        assert re.search(r".*Session opened on.*", lines[0])
        assert re.search(r".*Stored file.*", lines[1])

        commands.Find().run('all')
        out, err = capsys.readouterr()
        assert re.search(r".*\| 1 \| chromeinstall-8u31.exe.*", out)
        assert not re.search(r".*\| 2 \|.*", out)

        commands.Copy().run('-d', 'copy_test_dst')
        out, err = capsys.readouterr()
        lines = out.split('\n')
        assert re.search(r".*Copied:.*", lines[0])
        assert re.search(r".*Deleted:.*", lines[1])
        assert re.search(r".*Successfully copied sample.*", lines[2])

        commands.Find().run('all')
        out, err = capsys.readouterr()
        assert out == ""
        assert not re.search(r".*\| 1 \| chromeinstall-8u31.exe.*", out)
        assert not re.search(r".*\| 2 \|.*", out)

        commands.Projects().run('-s', 'copy_test_dst')
        out, err = capsys.readouterr()
        assert re.search(r".*Switched to project.*", out)

        commands.Find().run('all')
        out, err = capsys.readouterr()
        assert re.search(r".*\| 1 \| chromeinstall-8u31.exe.*", out)
        assert not re.search(r".*\| 2 \|.*", out)
示例#2
0
 def setup_method(self, method):
     """setUp by adding clean file"""
     # create api_test
     commands.Projects().run('-s', 'api_test')
     commands.Open().run(
         '-f', os.path.join(FIXTURE_DIR, "chromeinstall-8u31.exe"))
     commands.Store().run()
示例#3
0
    def teardown_method(self, method):
        """clean all files"""
        commands.Projects().run('-s', 'api_test')
        commands.Close().run()

        if sys.version_info <= (3, 0):
            in_fct = 'viper.core.ui.commands.input'
        else:
            in_fct = 'builtins.input'
        with mock.patch(in_fct, return_value='y'):
            commands.Delete().run('-a')
示例#4
0
    def test_projects(self, capsys):
        commands.Projects().run('-h')
        out, err = capsys.readouterr()
        assert re.search("usage: projects \[-h\] .*", out)

        p = Project()
        p.open("project_switch_test1")

        commands.Projects().run('-l')
        out, err = capsys.readouterr()
        assert re.search(".*Projects Available.*", out)
        assert re.search(".*project_switch_test1.*", out)
        assert not re.search(".*not_there.*", out)

        commands.Projects().run('-s', 'project_switch_test1')
        out, err = capsys.readouterr()
        lines = out.split('\n')
        assert re.search(".*Switched to project.*", lines[0])

        # return to default
        p.open("default")