Passed
Push — master ( a18d29...37d719 )
by benoit
01:08
created

test_debug_turned_on()   A

Complexity

Conditions 4

Size

Total Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
cc 4
c 2
b 0
f 0
dl 0
loc 5
rs 9.2
1
import os
0 ignored issues
show
Coding Style introduced by
This module should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
2
3
import pytest
0 ignored issues
show
introduced by
Unable to import 'pytest'
Loading history...
4
from click.testing import CliRunner
0 ignored issues
show
introduced by
Unable to import 'click.testing'
Loading history...
5
from testfixtures import LogCapture
0 ignored issues
show
introduced by
Unable to import 'testfixtures'
Loading history...
6
from src.gols import upload, cli
0 ignored issues
show
Bug introduced by
The name upload does not seem to exist in module src.gols.
Loading history...
7
8
from gols.cli import cli
0 ignored issues
show
introduced by
Unable to import 'gols.cli'
Loading history...
Unused Code introduced by
The import cli was already done on line 6. You should be able to
remove this line.
Loading history...
9
from gols.cli import upload
0 ignored issues
show
introduced by
Unable to import 'gols.cli'
Loading history...
Unused Code introduced by
The import upload was already done on line 6. You should be able to
remove this line.
Loading history...
10
11
12
@pytest.fixture(scope='function')
13
def runner():
0 ignored issues
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
14
    yield CliRunner()
15
16
17 View Code Duplication
@pytest.fixture(scope='function')
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
18
def fs():
0 ignored issues
show
Coding Style Naming introduced by
The name fs does not conform to the function naming conventions ((([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$).

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
19
    if not os.path.exists(os.path.join(os.path.dirname(os.path.dirname(__file__)), 'tests', 'directory_fit')):
0 ignored issues
show
Coding Style introduced by
This line is too long as per the coding-style (110/100).

This check looks for lines that are too long. You can specify the maximum line length.

Loading history...
20
        os.makedirs(os.path.join(os.path.dirname(os.path.dirname(__file__)), 'tests', 'directory_fit'))
0 ignored issues
show
Coding Style introduced by
This line is too long as per the coding-style (103/100).

This check looks for lines that are too long. You can specify the maximum line length.

Loading history...
21
    yield os.path.join(os.path.dirname(os.path.dirname(__file__)), 'tests', 'directory_fit')
22
23
24 View Code Duplication
@pytest.fixture(scope='function')
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
25
def cdf():
0 ignored issues
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
26
    if not os.path.exists(os.path.join(os.path.dirname(os.path.dirname(__file__)), 'tests', 'conf_dir_fit')):
0 ignored issues
show
Coding Style introduced by
This line is too long as per the coding-style (109/100).

This check looks for lines that are too long. You can specify the maximum line length.

Loading history...
27
        os.makedirs(os.path.join(os.path.dirname(os.path.dirname(__file__)), 'tests', 'conf_dir_fit'))
0 ignored issues
show
Coding Style introduced by
This line is too long as per the coding-style (102/100).

This check looks for lines that are too long. You can specify the maximum line length.

Loading history...
28
    yield os.path.join(os.path.dirname(os.path.dirname(__file__)), 'tests', 'conf_dir_fit')
29
30
31
def test_debug_turned_on(runner):
0 ignored issues
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
Comprehensibility Bug introduced by
runner is re-defining a name which is already available in the outer-scope (previously defined on line 13).

It is generally a bad practice to shadow variables from the outer-scope. In most cases, this is done unintentionally and might lead to unexpected behavior:

param = 5

class Foo:
    def __init__(self, param):   # "param" would be flagged here
        self.param = param
Loading history...
32
    with LogCapture() as l:
0 ignored issues
show
Coding Style Naming introduced by
The name l does not conform to the variable naming conventions ((([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$).

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
33
        result = runner.invoke(cli, ['--debug', 'upload'])
34
        assert result.exit_code == 2
35
        assert 'Debug level set on' in str(l)
36
37
38
def test_upload_help(runner):
0 ignored issues
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
Comprehensibility Bug introduced by
runner is re-defining a name which is already available in the outer-scope (previously defined on line 13).

It is generally a bad practice to shadow variables from the outer-scope. In most cases, this is done unintentionally and might lead to unexpected behavior:

param = 5

class Foo:
    def __init__(self, param):   # "param" would be flagged here
        self.param = param
Loading history...
39
    result = runner.invoke(upload, ['--help'])
40
    assert result.exit_code == 0
41
    assert 'Usage' in result.output
42
43
44
def test_required_fit_directory(runner, fs):
0 ignored issues
show
Coding Style Naming introduced by
The name fs does not conform to the argument naming conventions ((([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$).

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
Comprehensibility Bug introduced by
fs is re-defining a name which is already available in the outer-scope (previously defined on line 18).

It is generally a bad practice to shadow variables from the outer-scope. In most cases, this is done unintentionally and might lead to unexpected behavior:

param = 5

class Foo:
    def __init__(self, param):   # "param" would be flagged here
        self.param = param
Loading history...
Comprehensibility Bug introduced by
runner is re-defining a name which is already available in the outer-scope (previously defined on line 13).

It is generally a bad practice to shadow variables from the outer-scope. In most cases, this is done unintentionally and might lead to unexpected behavior:

param = 5

class Foo:
    def __init__(self, param):   # "param" would be flagged here
        self.param = param
Loading history...
45
    result = runner.invoke(upload, ['upload', fs])
46
    assert result.exit_code == 2
47
    assert 'Error: Missing option' in result.output
48
49
50
def test_upload_fit(runner, fs, cdf):
0 ignored issues
show
Coding Style Naming introduced by
The name fs does not conform to the argument naming conventions ((([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$).

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
Comprehensibility Bug introduced by
fs is re-defining a name which is already available in the outer-scope (previously defined on line 18).

It is generally a bad practice to shadow variables from the outer-scope. In most cases, this is done unintentionally and might lead to unexpected behavior:

param = 5

class Foo:
    def __init__(self, param):   # "param" would be flagged here
        self.param = param
Loading history...
Comprehensibility Bug introduced by
cdf is re-defining a name which is already available in the outer-scope (previously defined on line 25).

It is generally a bad practice to shadow variables from the outer-scope. In most cases, this is done unintentionally and might lead to unexpected behavior:

param = 5

class Foo:
    def __init__(self, param):   # "param" would be flagged here
        self.param = param
Loading history...
Comprehensibility Bug introduced by
runner is re-defining a name which is already available in the outer-scope (previously defined on line 13).

It is generally a bad practice to shadow variables from the outer-scope. In most cases, this is done unintentionally and might lead to unexpected behavior:

param = 5

class Foo:
    def __init__(self, param):   # "param" would be flagged here
        self.param = param
Loading history...
51
    username = '[email protected]'
52
    password = 'G0lsG0ls'
53
    with LogCapture() as l:
0 ignored issues
show
Coding Style Naming introduced by
The name l does not conform to the variable naming conventions ((([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$).

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
54
        # logger = logging.getLogger()
55
        result = runner.invoke(cli, ['--debug', 'upload', '-d', fs, '-c', cdf,
56
                                     '-u', username, '-p', password])
57
        print(result.output)
58
        print(l)
59
        assert result.exit_code == 0
60
        assert 'Done uploading'.format(fs) in str(l)
0 ignored issues
show
Bug introduced by
Too many arguments for format string
Loading history...
61
62
63
# @pytest.mark.parametrize('args, expected_output, expected_exit_code',
64
#                          [('', 'Error: Missing option', 2),
65
#                           (['-d /tmp'], 'Error: Invalid value for', 2),
66
#                           (['-d'],'',0)
67
#                           ])
68
# def test_upload_args(runnerfs, args, expected_output, expected_exit_code):
69
#     runner, fs = runnerfs
70
#     print(fs)
71
#     result = runner.invoke(upload, args=args)
72
#     assert result.exit_code == expected_exit_code
73
#     print(result.output)
74
#     assert expected_output in result.output
75