File: test_set_dev_version_cmd.py

package info (click to toggle)
trash-cli 0.24.5.26-0.3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,972 kB
  • sloc: python: 9,789; sh: 121; makefile: 11
file content (56 lines) | stat: -rw-r--r-- 1,922 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
from tests.support.put.fake_fs.fake_fs import FakeFs
from tests.test_dev_tools.support.run_set_dev_version import RunSetDevVersion


def adjust_py27(output):
    return output.replace("prg: error: too few arguments\n",
                          'prg: error: the following arguments '
                          'are required: ref, sha\n')


class TestSetDevVersionCmd:
    def setup_method(self):
        self.fs = FakeFs()
        self.run = RunSetDevVersion(self.fs)

    def test_when_no_args_fails(self, capsys):
        result = adjust_py27(self.run.run_cmd([], capsys))

        assert result == (
            'exit code: 2\n'
            'stderr: usage: prg [-h] ref sha\n'
            'prg: error: the following arguments are required: ref, sha\n'
            '\n'
            'stdout: \n'
            'filesystem:\n')

    def test_happy_path(self, capsys):
        self.fs.mkdir("trashcli")
        self.fs.write_file("trashcli/trash.py", "version = ...")

        result = self.run.run_cmd(['master', '12345b'], capsys)

        assert result == (
            'exit code: None\n'
            'stderr: \n'
            'stdout: \n'
            'filesystem:\n'
            "  /trashcli/trash.py: version = '0.24.5.13.dev0+git.master.12345b'"
        )

    def test(self, capsys):
        self.fs.mkdir("trashcli")
        self.fs.write_file("trashcli/trash.py", "version = ...")

        result = self.run.run_cmd(['-', '12345b'], capsys)

        assert result == (
            'exit code: 1\n'
            "stderr: Ref cannot contain '-': -\n"
            "The reason is because any '-' will be converted to '.' by "
            "setuptools during the egg_info phase that will result in an "
            "error in scripts/make-scripts because it will be not able to "
            "find the .tar.gz file\n\n"
            'stdout: \n'
            'filesystem:\n'
            '  /trashcli/trash.py: version = ...')