Пример #1
0
    def test_store_all_py3(self, capsys, filename):
        commands.Open().run('-f', os.path.join(FIXTURE_DIR, filename))
        commands.Store().run()
        commands.Store().run('-f', FIXTURE_DIR)
        out, err = capsys.readouterr()
        lines = out.split("\n")

        assert re.search(r".*Session opened on.*", lines[0])
        assert re.search(r".*appears to be already stored.*", out)
        assert re.search(
            r".*Skip, file \"chromeinstall-8u31.exe\" appears to be already stored.*",
            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 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)
Пример #4
0
    def test_store_unicode_py3(self, capsys, filename, name):
        # use cleandir fixture operate on clean ./ local dir
        copyfile(os.path.join(FIXTURE_DIR, filename),
                 os.path.join(".", os.path.basename(filename)))
        commands.Open().run('-f', os.path.join(".",
                                               os.path.basename(filename)))
        commands.Store().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()
        out, err = capsys.readouterr()
        lines = out.split("\n")

        assert re.search(r".*Session opened on.*", lines[0])
        assert not re.search(r".*Unable to store file.*", out)
        assert re.search(r".*{}.*".format(name), lines[1])
        assert re.search(r".*Running command.*", lines[5])
        assert re.search(r".*Deleted opened file.*", lines[7])
Пример #5
0
    def test_rename(self, capsys):
        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()
        _, _ = capsys.readouterr()

        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='chromeinstall-8u31.exe.new'):
            commands.Rename().run()
        out, err = capsys.readouterr()
        lines = out.split('\n')
        assert re.search(r".*Current name is.*1mchromeinstall-8u31.exe.*",
                         lines[0])
        assert re.search(r".*Refreshing session to update attributes.*",
                         lines[1])
Пример #6
0
 def test_store(self, capsys):
     commands.Store().run('-h')
     out, err = capsys.readouterr()
     assert re.search("usage: store \[-h\] .*", out)
Пример #7
0
 def setup_class(cls):
     commands.Open().run(
         '-f', os.path.join(FIXTURE_DIR, "chromeinstall-8u31.exe"))
     commands.Store().run()