Completed
Push — develop ( 604c57...dfb4a1 )
by Jace
8s
created

describe_cli()   C

Complexity

Conditions 7

Size

Total Lines 44

Duplication

Lines 0
Ratio 0 %

Importance

Changes 4
Bugs 0 Features 0
Metric Value
cc 7
dl 0
loc 44
rs 5.5
c 4
b 0
f 0

6 Methods

Rating   Name   Duplication   Size   Complexity  
A it_indicates_when_metrics_decrease() 0 6 1
A it_fails_when_metrics_decrease_if_requested() 0 6 1
A it_always_display_metrics_when_verbose() 0 6 1
A it_fails_when_missing_arguments() 0 5 1
A it_skips_when_running_on_ci() 0 8 1
A it_can_update_metrics() 0 6 1
1
# pylint: disable=redefined-outer-name,unused-variable,expression-not-assigned
2
3
from __future__ import unicode_literals
4
5
import os
6
import sys
7
8
import pytest
0 ignored issues
show
Configuration introduced by Jace Browning
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...
9
import scripttest
0 ignored issues
show
Configuration introduced by Jace Browning
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...
10
from expecter import expect
0 ignored issues
show
Configuration introduced by Jace Browning
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...
11
import six
12
13
SLUG = "jacebrowning/coverage-space-cli-demo"
14
15
16
@pytest.fixture
17
def env(tmpdir):
18
    path = str(tmpdir.join('test'))
19
    env = scripttest.TestFileEnvironment(path)
20
    env.environ.pop('TRAVIS', None)
21
    env.environ.pop('APPVEYOR', None)
22
    return env
23
24
25
def cli(env, *args):
26
    prog = os.path.join(os.path.dirname(sys.executable), 'coverage.space')
27
    cmd = env.run(prog, *args, expect_error=True)
28
    six.print_(cmd)
29
    return cmd
30
31
32
def describe_cli():
33
34
    def it_fails_when_missing_arguments(env):
35
        cmd = cli(env)
36
37
        expect(cmd.returncode) == 1
38
        expect(cmd.stderr).contains("Usage:")
39
40
    def it_can_update_metrics(env):
41
        cmd = cli(env, SLUG, 'unit', '100')
42
43
        expect(cmd.returncode) == 0
44
        expect(cmd.stderr) == ""
45
        expect(cmd.stdout) == ""
46
47
    def it_indicates_when_metrics_decrease(env):
48
        cmd = cli(env, SLUG, 'unit', '0')
49
50
        expect(cmd.returncode) == 0
51
        expect(cmd.stderr) == ""
52
        expect(cmd.stdout).contains("coverage decreased")
53
54
    def it_fails_when_metrics_decrease_if_requested(env):
55
        cmd = cli(env, SLUG, 'unit', '0', '--exit-code')
56
57
        expect(cmd.returncode) == 1
58
        expect(cmd.stderr) == ""
59
        expect(cmd.stdout).contains("coverage decreased")
60
61
    def it_always_display_metrics_when_verbose(env):
62
        cmd = cli(env, SLUG, 'unit', '100', '--verbose')
63
64
        expect(cmd.returncode) == 0
65
        expect(cmd.stderr) != ""  # expect lots of logging
66
        expect(cmd.stdout).contains("coverage increased")
67
68
    def it_skips_when_running_on_ci(env):
69
        env.environ['CIRCLECI'] = 'true'
70
71
        cmd = cli(env, SLUG, 'unit', '0', '--exit-code')
72
73
        expect(cmd.returncode) == 0
74
        expect(cmd.stderr).contains("Command skipped")
75
        expect(cmd.stdout) == ""
76