예제 #1
0
    def test_passed(self, m_boto):
        cwd = os.getcwd()
        try:
            config_path = Path(
                build_test_case("/tmp/lint_test_output/",
                                test_cases[0])).resolve()
            project_root = config_path.parent.parent
            config = Config.create(project_config_path=config_path,
                                   project_root=project_root)
            templates = config.get_templates()
            lint = Lint(config=config, templates=templates)
            self.assertEqual(lint.passed, True)

            lint_key = list(lint.lints[0])[0]
            result_key = list(lint.lints[0][lint_key]["results"])[0]
            test = lint.lints[0][lint_key]["results"][result_key]
            rule = mock.Mock(return_val="[E0001] some error")
            rule.rule.id = "E0001"
            rule.linenumber = 123
            rule.rule.shortdesc = "short error"
            rule.message = "some error"
            test.append(rule)
            lint.strict = True
            self.assertEqual(lint.passed, False)
        finally:
            shutil.rmtree("/tmp/lint_test_output/")
            os.chdir(cwd)
            pass
예제 #2
0
    def test_passed(self):
        cwd = os.getcwd()
        try:
            lint = Lint(
                config=Config(
                    project_config_path=str(
                        build_test_case("/tmp/lint_test_output/", test_cases[0])
                    ),
                    project_root="../",
                    create_clients=False,
                )
            )
            self.assertEqual(lint.passed, True)

            lint_key = [t for t in lint.lints[0]][0]
            result_key = [t for t in lint.lints[0][lint_key]["results"]][0]
            test = lint.lints[0][lint_key]["results"][result_key]
            rule = mock.Mock(return_val="[E0001] some error")
            rule.rule.id = "E0001"
            rule.linenumber = 123
            rule.rule.shortdesc = "short error"
            rule.message = "some error"
            test.append(rule)
            lint.strict = True
            self.assertEqual(lint.passed, False)
        finally:
            shutil.rmtree("/tmp/lint_test_output/")
            os.chdir(cwd)
            pass