Exemple #1
0
    def fix_and_check(self, args, id):
        from oelint_adv.__main__ import run

        # run for auto fixing
        run(args)
        # check run
        self.check_for_id(args, id, 0)
    def test_nowarn(self, input):
        # local imports only
        from oelint_adv.__main__ import run

        _args = self._create_args(input, extraopts=['--nowarn'])
        issues = [x[1] for x in run(_args)]
        assert (not any([x for x in issues if ':warning:' in x]))
    def test_messageformat_1(self, input):
        # local imports only
        from oelint_adv.__main__ import run

        _args = self._create_args(input,
                                  extraopts=['--messageformat="BAR:FOO"'])
        issues = [x[1] for x in run(_args)]
        assert (any([x for x in issues if 'BAR:FOO' in x]))
    def test_noid(self, input):
        # local imports only
        from oelint_adv.__main__ import run

        _args = self._create_args(input, extraopts=['--noid'])
        issues = [x[1] for x in run(_args)]
        assert (not any([x
                         for x in issues if ':oelint.vars.insaneskip:' in x]))
    def test_invalidfile(self):
        # local imports only
        from oelint_adv.__main__ import arguments_post
        from oelint_adv.__main__ import run

        _args = arguments_post(self._create_args_parser().parse_args(
            ['/does/not/exist']))
        issues = [x[1] for x in run(_args)]
        assert (not any(issues))
    def test_nonquiet(self, input):
        # local imports only
        from oelint_adv.__main__ import arguments_post
        from oelint_adv.__main__ import run

        _args = arguments_post(self._create_args_parser().parse_args(
            [self._create_tempfile(k, v) for k, v in input.items()]))
        issues = [x[1] for x in run(_args)]
        assert (any(issues))
    def test_messageformat_2(self, input):
        # local imports only
        from oelint_adv.__main__ import run

        _args = self._create_args(
            input, extraopts=['--messageformat="{id}:{severity}:{msg}"'])
        issues = [x[1] for x in run(_args)]
        assert (any(
            [x for x in issues if 'oelint.vars.insaneskip:error:' in x]))
    def test_rulefile(self, input):
        # local imports only
        from oelint_adv.__main__ import run

        _cstfile = self._create_tempfile('constants.json', '{}')

        _args = self._create_args(
            input, extraopts=['--rulefile={file}'.format(file=_cstfile)])
        issues = [x[1] for x in run(_args)]
        assert (any(issues))
    def test_rulefile_default_severity(self, input):
        # local imports only
        from oelint_adv.__main__ import run

        _rule_file = self._create_tempfile('rulefile',
                                           '{"oelint.var.mandatoryvar": ""}')
        _args = self._create_args(input,
                                  extraopts=[f'--rulefile={_rule_file}'])
        for issue in [x[1] for x in run(_args)]:
            assert ':error:' in issue
Exemple #10
0
 def check_for_id(self, args, id, occurrences):
     from oelint_adv.__main__ import run
     issues = [x[1] for x in run(args)]
     _files = '\n---\n'.join([
         '{k}:\n{v}'.format(k=k, v=v)
         for k, v in self.__created_files.items()
     ])
     assert (len([x for x in issues
                  if ':{id}:'.format(id=id) in x]) == occurrences
             ), '{id} expected {o} time(s) in:\n{i}\n\n---\n{f}'.format(
                 id=id, o=occurrences, i='\n'.join(issues), f=_files)
    def test_rulefile_filtering2(self, input):
        # local imports only
        from oelint_adv.__main__ import run

        _cstfile = self._create_tempfile(
            'constants.json',
            '{"oelint.var.mandatoryvar.DESCRIPTION": "warning"}')

        _args = self._create_args(
            input, extraopts=['--rulefile={file}'.format(file=_cstfile)])
        issues = [x[1] for x in run(_args)]
        assert (not any(issues))
    def test_relpaths(self, input):
        # local imports only
        from oelint_adv.__main__ import run

        _args = self._create_args(input, extraopts=['--relpaths'])
        _cwd = os.getcwd()
        os.chdir('/tmp')  # noqa: S108 - usage of tmp is fine for our purposes
        issues = [x[1] for x in run(_args)]
        assert (
            not any(x.startswith('/tmp/') for x in issues
                    ),  # noqa: S108 - usage of tmp is fine for our purposes
            'Expected relpaths in:\n{}'.format('\n'.join(issues)))
        os.chdir(_cwd)
    def test_color_input(self, input):
        # local imports only
        from colorama import Fore
        from oelint_adv.__main__ import run

        _args = self._create_args(input, extraopts=['--color'])
        issues = [x[1] for x in run(_args)]
        issues_formatted = '\n'.join(issues)
        assert (any(Fore.RED in x
                    for x in issues)), f'red expected in:\n{issues_formatted}'
        assert (any(
            Fore.YELLOW in x
            for x in issues)), f'yellow expected in:\n{issues_formatted}'
        assert (any(
            Fore.GREEN in x
            for x in issues)), f'green expected in:\n{issues_formatted}'