Пример #1
0
class Fixtures(enum.Enum):
    VALID_VIM_SCRIPT = get_fixture_path('prohibit_unused_variable_valid.vim')
    INVALID_VIM_SCRIPT = get_fixture_path(
        'prohibit_unused_variable_invalid.vim')
    ISSUE_274 = get_fixture_path('prohibit_unused_variable_issue_274.vim')
    IGNORED_PATTERNS = get_fixture_path(
        'prohibit_unused_variable_ignored_patterns.vim')
    README = get_fixture_path('prohibit_unused_variable_readme.vim')
Пример #2
0
import unittest
from test.asserting.policy import PolicyAssertion, get_fixture_path

from vint.linting.level import Level
from vint.linting.policy.prohibit_unnecessary_double_quote import ProhibitUnnecessaryDoubleQuote

PATH_VALID_VIM_SCRIPT = get_fixture_path(
    'prohibit_unnecessary_double_quote_valid.vim')
PATH_INVALID_VIM_SCRIPT = get_fixture_path(
    'prohibit_unnecessary_double_quote_invalid.vim')


class TestProhibitUnnecessaryDoubleQuote(PolicyAssertion, unittest.TestCase):
    def test_get_violation_if_found_when_file_is_valid(self):
        self.assertFoundNoViolations(PATH_VALID_VIM_SCRIPT,
                                     ProhibitUnnecessaryDoubleQuote)

    def test_get_violation_if_found_when_file_is_invalid(self):
        expected_violations = [
            {
                'name': 'ProhibitUnnecessaryDoubleQuote',
                'level': Level.WARNING,
                'position': {
                    'line': 2,
                    'column': 6,
                    'path': PATH_INVALID_VIM_SCRIPT
                },
            },
            {
                'name': 'ProhibitUnnecessaryDoubleQuote',
                'level': Level.WARNING,
Пример #3
0
import unittest
from test.asserting.policy import PolicyAssertion, get_fixture_path

from vint.linting.level import Level
from vint.linting.policy.prohibit_missing_scriptencoding import ProhibitMissingScriptEncoding

NO_MULTI_BYTE_CHAR_VIM_SCRIPT = get_fixture_path(
    'prohibit_missing_scriptencoding_valid_no_multibyte_char.vim')
SCRIPT_ENCODING_VIM_SCRIPT = get_fixture_path(
    'prohibit_missing_scriptencoding_valid_scriptencoding.vim')
INVALID_VIM_SCRIPT = get_fixture_path(
    'prohibit_missing_scriptencoding_invalid.vim')


class TestProhibitMissingScriptEncoding(PolicyAssertion, unittest.TestCase):
    def _create_violation_by_line_number(self, line_number):
        return {
            'name': 'ProhibitMissingScriptEncoding',
            'level': Level.WARNING,
            'position': {
                'line': line_number,
                'column': 1,
                'path': INVALID_VIM_SCRIPT
            }
        }

    def test_get_violation_if_found_with_valid_file_no_multibyte_char(self):
        self.assertFoundNoViolations(NO_MULTI_BYTE_CHAR_VIM_SCRIPT,
                                     ProhibitMissingScriptEncoding)

    def test_get_violation_if_found_with_valid_file_scriptencoding(self):
import unittest
from test.asserting.policy import PolicyAssertion, get_fixture_path

from vint.linting.level import Level
from vint.linting.policy.prohibit_encoding_opt_after_scriptencoding import (
    ProhibitEncodingOptionAfterScriptEncoding,
)


VALID_ORDER_VIM_SCRIPT = get_fixture_path(
    'prohibit_encoding_opt_after_scriptencoding_valid.vim'
)
NO_ENCODING_OPT_VIM_SCRIPT = get_fixture_path(
    'prohibit_encoding_opt_after_scriptencoding_valid_no_encoding_opt.vim'
)
NO_SCRIPT_ENCODING_VIM_SCRIPT = get_fixture_path(
    'prohibit_encoding_opt_after_scriptencoding_valid_no_scriptencoding.vim'
)
INVALID_ORDER_VIM_SCRIPT = get_fixture_path(
    'prohibit_encoding_opt_after_scriptencoding_invalid.vim'
)


class TestProhibitEncodingOptionAfterScriptEncoding(PolicyAssertion, unittest.TestCase):
    def _create_violation_by_line_number(self, line_number):
        return {
            'name': 'ProhibitEncodingOptionAfterScriptEncoding',
            'level': Level.WARNING,
            'position': {
                'line': line_number,
                'column': 1,
import unittest
from test.asserting.policy import PolicyAssertion, get_fixture_path

from vint.linting.level import Level
from vint.linting.policy.prohibit_missing_scriptencoding import ProhibitMissingScriptEncoding


NO_MULTI_BYTE_CHAR_VIM_SCRIPT = get_fixture_path('prohibit_missing_scriptencoding_valid_no_multibyte_char.vim')
SCRIPT_ENCODING_VIM_SCRIPT = get_fixture_path('prohibit_missing_scriptencoding_valid_scriptencoding.vim')
INVALID_VIM_SCRIPT = get_fixture_path('prohibit_missing_scriptencoding_invalid.vim')


class TestProhibitMissingScriptEncoding(PolicyAssertion, unittest.TestCase):
    def _create_violation_by_line_number(self, line_number):
        return {
            'name': 'ProhibitMissingScriptEncoding',
            'level': Level.WARNING,
            'position': {
                'line': line_number,
                'column': 1,
                'path': INVALID_VIM_SCRIPT
            }
        }


    def test_get_violation_if_found_with_valid_file_no_multibyte_char(self):
        self.assertFoundNoViolations(NO_MULTI_BYTE_CHAR_VIM_SCRIPT,
                                     ProhibitMissingScriptEncoding)


    def test_get_violation_if_found_with_valid_file_scriptencoding(self):
import unittest
from test.asserting.policy import PolicyAssertion, get_fixture_path

from vint.linting.level import Level
from vint.linting.policy.prohibit_command_rely_on_user import ProhibitCommandRelyOnUser

PATH_VALID_VIM_SCRIPT = get_fixture_path('prohibit_command_rely_on_user_valid.vim')
PATH_INVALID_VIM_SCRIPT = get_fixture_path('prohibit_command_rely_on_user_invalid.vim')


class TestProhibitCommandRelyOnUser(PolicyAssertion, unittest.TestCase):
    def test_get_violation_if_found_when_file_is_valid(self):
        self.assertFoundNoViolations(PATH_VALID_VIM_SCRIPT,
                                     ProhibitCommandRelyOnUser)


    def test_get_violation_if_found_when_file_is_invalid(self):
        expected_violations = [
            {
                'name': 'ProhibitCommandRelyOnUser',
                'level': Level.WARNING,
                'position': {
                    'line': 1,
                    'column': 1,
                    'path': PATH_INVALID_VIM_SCRIPT
                },
            },
            {
                'name': 'ProhibitCommandRelyOnUser',
                'level': Level.WARNING,
                'position': {
Пример #7
0
import unittest
from test.asserting.policy import PolicyAssertion, get_fixture_path

from vint.linting.level import Level
from vint.linting.policy.prohibit_set_nocompatible import ProhibitSetNoCompatible

INVALID_VIM_SCRIPT = get_fixture_path('prohibit_set_nocompatible_invalid.vim')
INVALID_VIM_SCRIPT_WITH_ABBREVIATION = get_fixture_path(
    'prohibit_set_nocompatible_invalid_with_abbreviation.vim')
VALID_VIM_SCRIPT = get_fixture_path('prohibit_set_nocompatible_valid.vim')


class TestProhibitSetNoCompatible(PolicyAssertion, unittest.TestCase):
    def create_violation(self, line_number, path):
        return {
            'name': 'ProhibitSetNoCompatible',
            'level': Level.WARNING,
            'position': {
                'line': line_number,
                'column': 1,
                'path': path
            }
        }

    def test_get_violation_if_found_with_valid(self):
        self.assertFoundNoViolations(VALID_VIM_SCRIPT, ProhibitSetNoCompatible)

    def test_get_violation_if_found_with_invalid_file(self):
        expected_violations = [
            self.create_violation(1, INVALID_VIM_SCRIPT),
        ]
import unittest
from test.asserting.policy import PolicyAssertion, get_fixture_path

from vint.linting.level import Level
from vint.linting.policy.prohibit_invalid_map_call import ProhibitInvalidMapCall

PATH_VALID_VIM_SCRIPT = get_fixture_path('prohibit_invalid_map_call_valid.vim')
PATH_INVALID_VIM_SCRIPT = get_fixture_path('prohibit_invalid_map_call_invalid.vim')


class TestProhibitInvalidMapCall(PolicyAssertion, unittest.TestCase):
    def test_get_violation_if_found_with_valid(self):
        self.assertFoundNoViolations(PATH_VALID_VIM_SCRIPT, ProhibitInvalidMapCall)


    def test_get_violation_if_found_with_invalid(self):
        expected_violations = [
            {
                'name': 'ProhibitInvalidMapCall',
                'level': Level.ERROR,
                'position': {
                    'line': 1,
                    'column': 16,
                    'path': PATH_INVALID_VIM_SCRIPT
                }
            }
        ]
        self.assertFoundViolationsEqual(PATH_INVALID_VIM_SCRIPT,
                                        ProhibitInvalidMapCall,
                                        expected_violations)
import unittest
from test.asserting.policy import PolicyAssertion, get_fixture_path

from vint.linting.level import Level
from vint.linting.policy.prohibit_invalid_map_call import ProhibitInvalidMapCall

PATH_VALID_VIM_SCRIPT = get_fixture_path('prohibit_invalid_map_call_valid.vim')
PATH_INVALID_VIM_SCRIPT = get_fixture_path(
    'prohibit_invalid_map_call_invalid.vim')


class TestProhibitInvalidMapCall(PolicyAssertion, unittest.TestCase):
    def test_get_violation_if_found_with_valid(self):
        self.assertFoundNoViolations(PATH_VALID_VIM_SCRIPT,
                                     ProhibitInvalidMapCall)

    def test_get_violation_if_found_with_invalid(self):
        expected_violations = [{
            'name': 'ProhibitInvalidMapCall',
            'level': Level.ERROR,
            'position': {
                'line': 1,
                'column': 16,
                'path': PATH_INVALID_VIM_SCRIPT
            }
        }]
        self.assertFoundViolationsEqual(PATH_INVALID_VIM_SCRIPT,
                                        ProhibitInvalidMapCall,
                                        expected_violations)
import unittest
from test.asserting.policy import PolicyAssertion, get_fixture_path

from vint.linting.level import Level
from vint.linting.policy.prohibit_autocmd_with_no_group import ProhibitAutocmdWithNoGroup


VALID_VIM_SCRIPT_WITH_AUGROUP = get_fixture_path(
    'prohibit_autocmd_with_no_group_valid_with_augroup.vim'
)
VALID_VIM_SCRIPT_WITH_GROUP_PARAM = get_fixture_path(
    'prohibit_autocmd_with_no_group_valid_with_group_param.vim'
)
INVALID_VIM_SCRIPT = get_fixture_path(
    'prohibit_autocmd_with_no_group_invalid.vim'
)


class TestProhibitAutocmdWithNoGroup(PolicyAssertion, unittest.TestCase):
    def create_violation(self, line_number, path):
        return {
            'name': 'ProhibitAutocmdWithNoGroup',
            'level': Level.WARNING,
            'position': {
                'line': line_number,
                'column': 1,
                'path': path
            }
        }

Пример #11
0
import unittest
from test.asserting.policy import PolicyAssertion, get_fixture_path

from vint.linting.level import Level
from vint.linting.policy.prohibit_encoding_opt_after_scriptencoding import (
    ProhibitEncodingOptionAfterScriptEncoding, )

VALID_ORDER_VIM_SCRIPT = get_fixture_path(
    'prohibit_encoding_opt_after_scriptencoding_valid.vim')
NO_ENCODING_OPT_VIM_SCRIPT = get_fixture_path(
    'prohibit_encoding_opt_after_scriptencoding_valid_no_encoding_opt.vim')
NO_SCRIPT_ENCODING_VIM_SCRIPT = get_fixture_path(
    'prohibit_encoding_opt_after_scriptencoding_valid_no_scriptencoding.vim')
INVALID_ORDER_VIM_SCRIPT = get_fixture_path(
    'prohibit_encoding_opt_after_scriptencoding_invalid.vim')


class TestProhibitEncodingOptionAfterScriptEncoding(PolicyAssertion,
                                                    unittest.TestCase):
    def _create_violation_by_line_number(self, line_number):
        return {
            'name': 'ProhibitEncodingOptionAfterScriptEncoding',
            'level': Level.WARNING,
            'position': {
                'line': line_number,
                'column': 1,
                'path': INVALID_ORDER_VIM_SCRIPT
            }
        }

    def test_get_violation_if_found_with_valid_file(self):
Пример #12
0
import unittest
from test.asserting.policy import PolicyAssertion, get_fixture_path

from vint.linting.level import Level
from vint.linting.policy.prohibit_command_with_unintended_side_effect import ProhibitCommandWithUnintendedSideEffect

PATH_VALID_VIM_SCRIPT = get_fixture_path('prohibit_command_with_unintended_side_effect_valid.vim')
PATH_INVALID_VIM_SCRIPT = get_fixture_path('prohibit_command_with_unintended_side_effect_invalid.vim')


class TestProhibitCommandWithUnintendedSideEffect(PolicyAssertion, unittest.TestCase):
    def _create_violation_by_line_number(self, line_number):
        return {
            'name': 'ProhibitCommandWithUnintendedSideEffect',
            'level': Level.WARNING,
            'position': {
                'line': line_number,
                'column': 1,
                'path': PATH_INVALID_VIM_SCRIPT
            }
        }


    def test_get_violation_if_found_with_valid_file(self):
        self.assertFoundNoViolations(PATH_VALID_VIM_SCRIPT,
                                     ProhibitCommandWithUnintendedSideEffect)


    def test_get_violation_if_found_with_invalid_file(self):
        expected_violations = [self._create_violation_by_line_number(line_number)
                               for line_number in range(1, 14)]
import unittest
from test.asserting.policy import PolicyAssertion, get_fixture_path

from vint.linting.level import Level
from vint.linting.policy.prohibit_command_rely_on_user import ProhibitCommandRelyOnUser

PATH_VALID_VIM_SCRIPT = get_fixture_path(
    'prohibit_command_rely_on_user_valid.vim')
PATH_INVALID_VIM_SCRIPT = get_fixture_path(
    'prohibit_command_rely_on_user_invalid.vim')


class TestProhibitCommandRelyOnUser(PolicyAssertion, unittest.TestCase):
    def test_get_violation_if_found_when_file_is_valid(self):
        self.assertFoundNoViolations(PATH_VALID_VIM_SCRIPT,
                                     ProhibitCommandRelyOnUser)

    def test_get_violation_if_found_when_file_is_invalid(self):
        expected_violations = [
            {
                'name': 'ProhibitCommandRelyOnUser',
                'level': Level.WARNING,
                'position': {
                    'line': 1,
                    'column': 1,
                    'path': PATH_INVALID_VIM_SCRIPT
                },
            },
            {
                'name': 'ProhibitCommandRelyOnUser',
                'level': Level.WARNING,
Пример #14
0
import unittest
from test.asserting.policy import PolicyAssertion, get_fixture_path

from vint.linting.level import Level
from vint.linting.policy.prohibit_set_nocompatible import ProhibitSetNoCompatible


INVALID_VIM_SCRIPT = get_fixture_path(
    'prohibit_set_nocompatible_invalid.vim'
)
INVALID_VIM_SCRIPT_WITH_ABBREVIATION = get_fixture_path(
    'prohibit_set_nocompatible_invalid_with_abbreviation.vim'
)
VALID_VIM_SCRIPT = get_fixture_path(
    'prohibit_set_nocompatible_valid.vim'
)


class TestProhibitSetNoCompatible(PolicyAssertion, unittest.TestCase):
    def create_violation(self, line_number, path):
        return {
            'name': 'ProhibitSetNoCompatible',
            'level': Level.WARNING,
            'position': {
                'line': line_number,
                'column': 1,
                'path': path
            }
        }

import unittest
from test.asserting.policy import PolicyAssertion, get_fixture_path

from vint.linting.level import Level
from vint.linting.policy.prohibit_implicit_scope_variable import ProhibitImplicitScopeVariable

PATH_VALID_VIM_SCRIPT = get_fixture_path(
    'prohibit_implicit_scope_variable_valid.vim')
PATH_INVALID_VIM_SCRIPT = get_fixture_path(
    'prohibit_implicit_scope_variable_invalid.vim')


class TestProhibitImplicitScopeVariable(PolicyAssertion, unittest.TestCase):
    def test_get_violation_if_found_when_file_is_valid(self):
        self.assertFoundNoViolations(PATH_VALID_VIM_SCRIPT,
                                     ProhibitImplicitScopeVariable)

    def create_violation(self, line, column):
        return {
            'name': 'ProhibitImplicitScopeVariable',
            'level': Level.STYLE_PROBLEM,
            'position': {
                'line': line,
                'column': column,
                'path': PATH_INVALID_VIM_SCRIPT
            }
        }

    def test_get_violation_if_found_when_file_is_invalid(self):
        expected_violations = [
            self.create_violation(2, 5),
import unittest
from test.asserting.policy import PolicyAssertion, get_fixture_path

from vint.linting.level import Level
from vint.linting.policy.prohibit_no_abort_function import ProhibitNoAbortFunction

PATH_VALID_VIM_SCRIPT_1 = get_fixture_path('prohibit_no_abort_function_valid.vim')
PATH_VALID_VIM_SCRIPT_2 = get_fixture_path('autoload', 'prohibit_no_abort_function_valid.vim')
PATH_INVALID_VIM_SCRIPT = get_fixture_path('autoload', 'prohibit_no_abort_function_invalid.vim')


class TestProhibitNoAbortFunction(PolicyAssertion, unittest.TestCase):
    def test_get_violation_if_found_when_file_is_valid(self):
        self.assertFoundNoViolations(PATH_VALID_VIM_SCRIPT_1,
                                     ProhibitNoAbortFunction)


    def test_get_violation_if_found_when_file_is_valid_out_of_autoload(self):
        self.assertFoundNoViolations(PATH_VALID_VIM_SCRIPT_2,
                                     ProhibitNoAbortFunction)


    def test_get_violation_if_found_when_file_is_invalid(self):
        expected_violations = [
            {
                'name': 'ProhibitNoAbortFunction',
                'level': Level.WARNING,
                'position': {
                    'line': 1,
                    'column': 1,
                    'path': PATH_INVALID_VIM_SCRIPT
Пример #17
0
import unittest
from test.asserting.policy import PolicyAssertion, get_fixture_path

from vint.linting.level import Level
from vint.linting.policy.prohibit_no_abort_function import ProhibitNoAbortFunction

PATH_VALID_VIM_SCRIPT_1 = get_fixture_path(
    'prohibit_no_abort_function_valid.vim')
PATH_VALID_VIM_SCRIPT_2 = get_fixture_path(
    'autoload', 'prohibit_no_abort_function_valid.vim')
PATH_INVALID_VIM_SCRIPT = get_fixture_path(
    'autoload', 'prohibit_no_abort_function_invalid.vim')


class TestProhibitNoAbortFunction(PolicyAssertion, unittest.TestCase):
    def test_get_violation_if_found_when_file_is_valid(self):
        self.assertFoundNoViolations(PATH_VALID_VIM_SCRIPT_1,
                                     ProhibitNoAbortFunction)

    def test_get_violation_if_found_when_file_is_valid_out_of_autoload(self):
        self.assertFoundNoViolations(PATH_VALID_VIM_SCRIPT_2,
                                     ProhibitNoAbortFunction)

    def test_get_violation_if_found_when_file_is_invalid(self):
        expected_violations = [
            {
                'name': 'ProhibitNoAbortFunction',
                'level': Level.WARNING,
                'position': {
                    'line': 1,
                    'column': 1,
import unittest
from test.asserting.policy import PolicyAssertion, get_fixture_path

from vint.linting.level import Level
from vint.linting.policy.prohibit_autocmd_with_no_group import ProhibitAutocmdWithNoGroup

VALID_VIM_SCRIPT_WITH_AUGROUP = get_fixture_path(
    'prohibit_autocmd_with_no_group_valid_with_augroup.vim')
VALID_VIM_SCRIPT_WITH_GROUP_PARAM = get_fixture_path(
    'prohibit_autocmd_with_no_group_valid_with_group_param.vim')
INVALID_VIM_SCRIPT = get_fixture_path(
    'prohibit_autocmd_with_no_group_invalid.vim')


class TestProhibitAutocmdWithNoGroup(PolicyAssertion, unittest.TestCase):
    def create_violation(self, line_number, path):
        return {
            'name': 'ProhibitAutocmdWithNoGroup',
            'level': Level.WARNING,
            'position': {
                'line': line_number,
                'column': 1,
                'path': path
            }
        }

    def test_get_violation_if_found_with_valid_file_with_augroup(self):
        self.assertFoundNoViolations(VALID_VIM_SCRIPT_WITH_AUGROUP,
                                     ProhibitAutocmdWithNoGroup)

    def test_get_violation_if_found_with_valid_file_with_group_param(self):
import unittest
from test.asserting.policy import PolicyAssertion, get_fixture_path

from vint.linting.level import Level
from vint.linting.policy.prohibit_equal_tilde_operator import ProhibitEqualTildeOperator

PATH_VALID_VIM_SCRIPT = get_fixture_path('prohibit_equal_tilde_operator_valid.vim')
PATH_INVALID_VIM_SCRIPT = get_fixture_path('prohibit_equal_tilde_operator_invalid.vim')


class TestProhibitEqualTildeOperator(PolicyAssertion, unittest.TestCase):
    def test_get_violation_if_found_when_file_is_valid(self):
        self.assertFoundNoViolations(PATH_VALID_VIM_SCRIPT,
                                     ProhibitEqualTildeOperator)


    def test_get_violation_if_found_when_file_is_invalid(self):
        expected_violations = [
            {
                'name': 'ProhibitEqualTildeOperator',
                'level': Level.WARNING,
                'position': {
                    'line': 2,
                    'column': 12,
                    'path': PATH_INVALID_VIM_SCRIPT
                },
            },
            {
                'name': 'ProhibitEqualTildeOperator',
                'level': Level.WARNING,
                'position': {
Пример #20
0
import unittest
from test.asserting.policy import PolicyAssertion, get_fixture_path

from vint.linting.level import Level
from vint.linting.policy.prohibit_equal_tilde_operator import ProhibitEqualTildeOperator

PATH_VALID_VIM_SCRIPT = get_fixture_path(
    'prohibit_equal_tilde_operator_valid.vim')
PATH_INVALID_VIM_SCRIPT = get_fixture_path(
    'prohibit_equal_tilde_operator_invalid.vim')


class TestProhibitEqualTildeOperator(PolicyAssertion, unittest.TestCase):
    def test_get_violation_if_found_when_file_is_valid(self):
        self.assertFoundNoViolations(PATH_VALID_VIM_SCRIPT,
                                     ProhibitEqualTildeOperator)

    def test_get_violation_if_found_when_file_is_invalid(self):
        expected_violations = [
            {
                'name': 'ProhibitEqualTildeOperator',
                'level': Level.WARNING,
                'position': {
                    'line': 2,
                    'column': 12,
                    'path': PATH_INVALID_VIM_SCRIPT
                },
            },
            {
                'name': 'ProhibitEqualTildeOperator',
                'level': Level.WARNING,
Пример #21
0
import unittest
from test.asserting.policy import PolicyAssertion, get_fixture_path

from vint.linting.level import Level
from vint.linting.policy.prohibit_abbreviation_option import ProhibitAbbreviationOption

VALID_VIM_SCRIPT = get_fixture_path('prohibit_abbreviation_option_valid.vim')
INVALID_SET_VIM_SCRIPT = get_fixture_path('prohibit_abbreviation_option_invalid_with_set.vim')
INVALID_VAR_VIM_SCRIPT = get_fixture_path('prohibit_abbreviation_option_invalid_with_var.vim')


class TestProhibitAbbreviationOption(PolicyAssertion, unittest.TestCase):
    def create_violation(self, line_number, col_number, path):
        return {
            'name': 'ProhibitAbbreviationOption',
            'level': Level.STYLE_PROBLEM,
            'position': {
                'line': line_number,
                'column': col_number,
                'path': path,
            },
        }


    def test_get_violation_if_found_when_file_is_valid(self):
        self.assertFoundNoViolations(VALID_VIM_SCRIPT,
                                     ProhibitAbbreviationOption)


    def test_get_violation_if_found_when_file_is_invalid_with_set(self):
        expected_violations = [
import unittest
from test.asserting.policy import PolicyAssertion, get_fixture_path

from vint.linting.level import Level
from vint.linting.policy.prohibit_unnecessary_double_quote import ProhibitUnnecessaryDoubleQuote

PATH_VALID_VIM_SCRIPT = get_fixture_path('prohibit_unnecessary_double_quote_valid.vim')
PATH_INVALID_VIM_SCRIPT = get_fixture_path('prohibit_unnecessary_double_quote_invalid.vim')


class TestProhibitUnnecessaryDoubleQuote(PolicyAssertion, unittest.TestCase):
    def test_get_violation_if_found_when_file_is_valid(self):
        self.assertFoundNoViolations(PATH_VALID_VIM_SCRIPT,
                                     ProhibitUnnecessaryDoubleQuote)


    def test_get_violation_if_found_when_file_is_invalid(self):
        expected_violations = [
            {
                'name': 'ProhibitUnnecessaryDoubleQuote',
                'level': Level.WARNING,
                'position': {
                    'line': 2,
                    'column': 6,
                    'path': PATH_INVALID_VIM_SCRIPT
                },
            },
            {
                'name': 'ProhibitUnnecessaryDoubleQuote',
                'level': Level.WARNING,
                'position': {
import unittest
from test.asserting.policy import PolicyAssertion, get_fixture_path

from vint.linting.level import Level
from vint.linting.policy.prohibit_implicit_scope_variable import ProhibitImplicitScopeVariable

PATH_VALID_VIM_SCRIPT = get_fixture_path('prohibit_implicit_scope_variable_valid.vim')
PATH_INVALID_VIM_SCRIPT = get_fixture_path('prohibit_implicit_scope_variable_invalid.vim')


class TestProhibitImplicitScopeVariable(PolicyAssertion, unittest.TestCase):
    def test_get_violation_if_found_when_file_is_valid(self):
        self.assertFoundNoViolations(PATH_VALID_VIM_SCRIPT,
                                     ProhibitImplicitScopeVariable)


    def create_violation(self, line, column):
        return {
            'name': 'ProhibitImplicitScopeVariable',
            'level': Level.STYLE_PROBLEM,
            'position': {
                'line': line,
                'column': column,
                'path': PATH_INVALID_VIM_SCRIPT
            }
        }


    def test_get_violation_if_found_when_file_is_invalid(self):
        expected_violations = [
            self.create_violation(2, 5),
import unittest
from test.asserting.policy import PolicyAssertion, get_fixture_path

from vint.linting.level import Level
from vint.linting.policy.prohibit_command_with_unintended_side_effect import ProhibitCommandWithUnintendedSideEffect

PATH_VALID_VIM_SCRIPT = get_fixture_path('prohibit_command_with_unintended_side_effect_valid.vim')
PATH_INVALID_VIM_SCRIPT = get_fixture_path('prohibit_command_with_unintended_side_effect_invalid.vim')


class TestProhibitCommandWithUnintendedSideEffect(PolicyAssertion, unittest.TestCase):
    def _create_violation_by_line_number(self, line_number):
        return {
            'name': 'ProhibitCommandWithUnintendedSideEffect',
            'level': Level.WARNING,
            'position': {
                'line': line_number,
                'column': 1,
                'path': PATH_INVALID_VIM_SCRIPT
            }
        }


    def test_get_violation_if_found_with_valid_file(self):
        self.assertFoundNoViolations(PATH_VALID_VIM_SCRIPT,
                                     ProhibitCommandWithUnintendedSideEffect)


    def test_get_violation_if_found_with_invalid_file(self):
        expected_violations = [self._create_violation_by_line_number(line_number)
                               for line_number in range(1, 12)]
import unittest
from test.asserting.policy import PolicyAssertion, get_fixture_path

from vint.linting.level import Level
from vint.linting.policy.prohibit_using_undeclared_variable import ProhibitUsingUndeclaredVariable

PATH_VALID_VIM_SCRIPT = get_fixture_path('prohibit_using_undeclared_variable_valid.vim')
PATH_INVALID_VIM_SCRIPT = get_fixture_path('prohibit_using_undeclared_variable_invalid.vim')


class TestProhibitUsingUndeclaredVariable(PolicyAssertion, unittest.TestCase):
    @unittest.skip('because ScopePlugin is temporary disabled')
    def test_get_violation_if_found_when_file_is_valid(self):
        self.assertFoundNoViolations(PATH_VALID_VIM_SCRIPT,
                                     ProhibitUsingUndeclaredVariable)


    @unittest.skip('because ScopePlugin is temporary disabled')
    def test_get_violation_if_found_when_file_is_invalid(self):
        expected_violations = [
            {
                'name': 'ProhibitUsingUndeclaredVariable',
                'level': Level.WARNING,
                'position': {
                    'line': 1,
                    'column': 6,
                    'path': PATH_INVALID_VIM_SCRIPT
                },
            },
            {
                'name': 'ProhibitUsingUndeclaredVariable',