tests.test_cli   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 5
eloc 26
dl 0
loc 39
rs 10
c 0
b 0
f 0

3 Functions

Rating   Name   Duplication   Size   Complexity  
A describe_cli() 0 7 1
A runner() 0 3 1
A test_clean_channel() 0 15 3
1
# pylint: disable=redefined-outer-name,unused-variable,expression-not-assigned
2
3
import pytest
4
from click.testing import CliRunner
5
from expecter import expect
6
7
from slackoff.cli import clean_channel, main
8
9
10
@pytest.fixture
11
def runner():
12
    return CliRunner()
13
14
15
def describe_cli():
16
    def describe_signout():
17
        def it_can_force_signin(runner):
18
            result = runner.invoke(main, ["Foobar", "--signout"])
19
20
            expect(result.output) == "Currently signed out of Foobar\n"
21
            expect(result.exit_code) == 0
22
23
24
@pytest.mark.parametrize(
25
    ("before", "after"),
26
    [
27
        ("foobar", "foobar"),
28
        ("#foobar ", "foobar"),
29
        ("# ", None),
30
        (" ", None),
31
    ],
32
)
33
def test_clean_channel(before, after):
34
    if after is None:
35
        with expect.raises(Exception):
36
            clean_channel(None, None, before)
37
    else:
38
        expect(clean_channel(None, None, before)) == after
39