Completed
Pull Request — develop (#14)
by Jace
02:28 queued 01:27
created

it_displays_version_information()   A

Complexity

Conditions 1

Size

Total Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
dl 0
loc 5
rs 9.4285
c 0
b 0
f 0
1
# -*- coding: utf-8 -*-
2
# pylint: disable=redefined-outer-name,unused-variable,expression-not-assigned
3
4
from __future__ import unicode_literals
5
6
import os
7
import sys
8
import logging
9
10
import pytest
0 ignored issues
show
Configuration introduced by
The import pytest could not be resolved.

This can be caused by one of the following:

1. Missing Dependencies

This error could indicate a configuration issue of Pylint. Make sure that your libraries are available by adding the necessary commands.

# .scrutinizer.yml
before_commands:
    - sudo pip install abc # Python2
    - sudo pip3 install abc # Python3
Tip: We are currently not using virtualenv to run pylint, when installing your modules make sure to use the command for the correct version.

2. Missing __init__.py files

This error could also result from missing __init__.py files in your module folders. Make sure that you place one file in each sub-folder.

Loading history...
11
import scripttest
0 ignored issues
show
Configuration introduced by
The import scripttest could not be resolved.

This can be caused by one of the following:

1. Missing Dependencies

This error could indicate a configuration issue of Pylint. Make sure that your libraries are available by adding the necessary commands.

# .scrutinizer.yml
before_commands:
    - sudo pip install abc # Python2
    - sudo pip3 install abc # Python3
Tip: We are currently not using virtualenv to run pylint, when installing your modules make sure to use the command for the correct version.

2. Missing __init__.py files

This error could also result from missing __init__.py files in your module folders. Make sure that you place one file in each sub-folder.

Loading history...
12
from expecter import expect
0 ignored issues
show
Configuration introduced by
The import expecter could not be resolved.

This can be caused by one of the following:

1. Missing Dependencies

This error could indicate a configuration issue of Pylint. Make sure that your libraries are available by adding the necessary commands.

# .scrutinizer.yml
before_commands:
    - sudo pip install abc # Python2
    - sudo pip3 install abc # Python3
Tip: We are currently not using virtualenv to run pylint, when installing your modules make sure to use the command for the correct version.

2. Missing __init__.py files

This error could also result from missing __init__.py files in your module folders. Make sure that you place one file in each sub-folder.

Loading history...
13
14
15
ROOT = os.path.abspath(os.path.dirname(__file__))
16
FILES = os.path.join(ROOT, "files")
17
BIN = os.path.join(FILES, "bin")
18
19
SAMPLE_OUTPUT = """
20
Checking for Valid Program...
21
22
$ working --version
23
1.2.3
24
✔ MATCHED: 1.2.
25
26
Checking for Invalid Program...
27
28
$ working --version
29
1.2.3
30
✖ EXPECTED: 4.
31
32
Checking for Broken Program...
33
34
$ broken --version
35
An error occurred.
36
✖ EXPECTED: 1.2.3
37
38
Checking for Missing Program...
39
40
$ missing --version
41
sh: command not found: missing
42
✖ EXPECTED: 1.2.3
43
44
Results: ✔ ✖ ✖ ✖
45
46
"""
47
48
log = logging.getLogger(__name__)
49
50
51
@pytest.fixture
52
def env(tmpdir):
53
    path = str(tmpdir.join("test"))
54
    env = scripttest.TestFileEnvironment(path)
55
    return env
56
57
58
@pytest.fixture
59
def env_with_bin(env):
60
    env.environ['PATH'] = BIN
61
    log.debug("ENV: %s", env.environ)
62
    return env
63
64
65
def cli(env, *args):
66
    prog = os.path.join(os.path.dirname(sys.executable), "verchew")
67
    cmd = env.run(prog, *args, expect_error=True)
68
    return cmd
69
70
71
def describe_cli():
72
73
    def it_displays_help_information(env):
74
        cmd = cli(env, '--help')
75
76
        expect(cmd.returncode) == 0
77
        expect(cmd.stdout).contains("usage: verchew")
78
79
    def it_displays_version_information(env):
80
        cmd = cli(env, '--version')
81
82
        expect(cmd.returncode) == 0
83
        expect(cmd.stdout or cmd.stderr).contains("verchew v0.")
84
85
    def it_displays_results_when_run(env_with_bin):
86
        cmd = cli(env_with_bin, '--root', FILES)
87
88
        expect(cmd.returncode) == 1
89
        expect(cmd.stderr) == ""
90
        expect(cmd.stdout) == SAMPLE_OUTPUT
91