# -*- coding: utf-8 -*-
from __future__ import absolute_import
from mock import patch, Mock
from pytest import raises
from fabutils.lint import LintError, lint_files


@patch('fabutils.lint.print', Mock())
@patch('fabutils.lint.infomsg', Mock())
def test_raises_ValueError_if_passed_iterable_is_actually_a_string():
    with raises(ValueError):
        lint_files('fakepath')


@patch('fabutils.lint.print', Mock())
@patch('fabutils.lint.infomsg', Mock())
def test_raises_LintError_if_passed_paths_is_an_empty_list():
    with raises(LintError):
        lint_files([])



@patch('fabutils.lint.infomsg', Mock())
@patch('fabutils.lint.print', Mock())
@patch('fabutils.lint.is_pep8_compliant')
@patch('fabutils.lint.is_pylint_compliant')
def test_calls_linters_with_the_same_list_of_paths_as_given(
        is_statically_correct,
        is_pep8_compliant
):
    lint_files(['fakepath'])

    is_pep8_compliant.assert_called_with(['fakepath'])
    is_statically_correct.assert_called_with(['fakepath'])
