Example #1
0
 def test_iterate_commands(self):
     """test iterate_commands."""
     yaml_dict = load(TestRulebreaker.RULEBREAKER.format(inject_here=""))
     gen = iterate_commands(yaml_dict)
     count = 0
     for _ in gen:
         count = count + 1
     self.assertEqual(count, 14)
Example #2
0
 def test_iterate_commands_no_commands(self):
     """Test iterate_commands when the yaml has no commands."""
     yaml_dict = load(TestHelpers.I_CANT_BELIEVE_THAT_VALIDATES)
     gen = iterate_commands(yaml_dict)
     count = 0
     for _ in gen:
         count = count + 1
     self.assertEqual(count, 0)
Example #3
0
 def test_iterate_fn_calls_context(self):
     """Test iterate_fn_calls_context."""
     yaml_dict = load(TestRulebreaker.RULEBREAKER.format(inject_here=""))
     gen = h.iterate_fn_calls_context(yaml_dict)
     count = 0
     for _ in gen:
         count = count + 1
     self.assertEqual(count, 2)
Example #4
0
        def test_rule(self):
            """Test self.func with the yamls listed in self.table, and compare results."""

            for expectation in self.table:
                yaml_dict = load(expectation["raw_yaml"])
                errors = self.func(yaml_dict)
                # a discrepancy on this assert means that your rule isn't working
                # as expected
                self.assertListEqual(errors, expectation["errors"])
Example #5
0
    def _gen_rule_breaker(cls) -> dict:
        # List from https://github.com/evergreen-ci/evergreen/wiki/Project-Commands
        commands = [
            "keyval.inc",
            "archive.targz_extract",
            "archive.targz_pack",
            "attach.artifacts",
            "attach.results",
            "attach.xunit_results",
            "expansions.update",
            "expansions.write",
            "generate.tasks",
            "git.get_project",
            "gotest.parse_files",
            "host.create",
            "host.list",
            "json.send",
            "manifest.load",
            "perf.send",
            "s3.get",
            "s3.put",
            "s3.push",
            "s3.pull",
            "s3Copy.copy",
            "shell.exec",
            "subprocess.exec",
            "subprocess.scripting",
            "timeout.update",
        ]
        buf = StringIO()
        for cmd in commands:
            buf.write(f"        - command: {cmd}\n")

        gen_commands = TestRulebreaker.RULEBREAKER.format(
            inject_here=buf.getvalue())
        return load(gen_commands)