Skip to content

Commit

Permalink
Cleanup testing
Browse files Browse the repository at this point in the history
  • Loading branch information
kddejong committed Apr 25, 2024
1 parent 942db17 commit d625761
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 16 deletions.
4 changes: 4 additions & 0 deletions test/integration/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import json
import subprocess
import sys
from pathlib import Path
from test.testlib.testcase import BaseTestCase

import cfnlint.core
Expand Down Expand Up @@ -93,6 +94,9 @@ def run_module_integration_scenarios(self, rules):
with open(results_filename, encoding="utf-8") as json_data:
expected_results = json.load(json_data)

for result in expected_results:
result["Filename"] = str(Path(result.get("Filename")))

template = cfnlint.decode.cfn_yaml.load(filename)

matches = cfnlint.core.run_checks(filename, template, rules, regions)
Expand Down
25 changes: 18 additions & 7 deletions test/integration/test_directives.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
SPDX-License-Identifier: MIT-0
"""

from pathlib import Path
from test.integration import BaseCliTestCase


Expand All @@ -11,16 +12,18 @@ class TestDirectives(BaseCliTestCase):

scenarios = [
{
"filename": "test/fixtures/templates/good/core/directives.yaml",
"filename": str(Path("test/fixtures/templates/good/core/directives.yaml")),
"exit_code": 0,
"results": [],
},
{
"filename": "test/fixtures/templates/bad/core/directives.yaml",
"filename": str(Path("test/fixtures/templates/bad/core/directives.yaml")),
"exit_code": 2,
"results": [
{
"Filename": "test/fixtures/templates/bad/core/directives.yaml",
"Filename": str(
Path("test/fixtures/templates/bad/core/directives.yaml")
),
"Level": "Error",
"Location": {
"End": {"ColumnNumber": 18, "LineNumber": 17},
Expand All @@ -41,7 +44,9 @@ class TestDirectives(BaseCliTestCase):
},
},
{
"Filename": "test/fixtures/templates/bad/core/directives.yaml",
"Filename": str(
Path("test/fixtures/templates/bad/core/directives.yaml")
),
"Level": "Error",
"Location": {
"End": {"ColumnNumber": 13, "LineNumber": 28},
Expand All @@ -62,7 +67,9 @@ class TestDirectives(BaseCliTestCase):
},
},
{
"Filename": "test/fixtures/templates/bad/core/directives.yaml",
"Filename": str(
Path("test/fixtures/templates/bad/core/directives.yaml")
),
"Level": "Error",
"Location": {
"End": {"ColumnNumber": 16, "LineNumber": 32},
Expand All @@ -82,7 +89,9 @@ class TestDirectives(BaseCliTestCase):
},
},
{
"Filename": "test/fixtures/templates/bad/core/directives.yaml",
"Filename": str(
Path("test/fixtures/templates/bad/core/directives.yaml")
),
"Level": "Error",
"Location": {
"End": {"ColumnNumber": 13, "LineNumber": 35},
Expand All @@ -103,7 +112,9 @@ class TestDirectives(BaseCliTestCase):
},
},
{
"Filename": "test/fixtures/templates/bad/core/directives.yaml",
"Filename": str(
Path("test/fixtures/templates/bad/core/directives.yaml")
),
"Level": "Error",
"Location": {
"End": {"ColumnNumber": 15, "LineNumber": 37},
Expand Down
33 changes: 25 additions & 8 deletions test/integration/test_mandatory_checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
SPDX-License-Identifier: MIT-0
"""

from pathlib import Path
from test.integration import BaseCliTestCase


Expand All @@ -11,11 +12,15 @@ class TestDirectives(BaseCliTestCase):

scenarios = [
{
"filename": "test/fixtures/templates/bad/core/mandatory_checks.yaml",
"filename": str(
Path("test/fixtures/templates/bad/core/mandatory_checks.yaml")
),
"exit_code": 2,
"results": [
{
"Filename": "test/fixtures/templates/bad/core/mandatory_checks.yaml",
"Filename": str(
Path("test/fixtures/templates/bad/core/mandatory_checks.yaml")
),
"Level": "Error",
"Location": {
"End": {"ColumnNumber": 18, "LineNumber": 17},
Expand All @@ -36,7 +41,9 @@ class TestDirectives(BaseCliTestCase):
},
},
{
"Filename": "test/fixtures/templates/bad/core/mandatory_checks.yaml",
"Filename": str(
Path("test/fixtures/templates/bad/core/mandatory_checks.yaml")
),
"Level": "Error",
"Location": {
"End": {"ColumnNumber": 13, "LineNumber": 28},
Expand All @@ -57,7 +64,9 @@ class TestDirectives(BaseCliTestCase):
},
},
{
"Filename": "test/fixtures/templates/bad/core/mandatory_checks.yaml",
"Filename": str(
Path("test/fixtures/templates/bad/core/mandatory_checks.yaml")
),
"Level": "Error",
"Location": {
"End": {"ColumnNumber": 16, "LineNumber": 32},
Expand All @@ -77,7 +86,9 @@ class TestDirectives(BaseCliTestCase):
},
},
{
"Filename": "test/fixtures/templates/bad/core/mandatory_checks.yaml",
"Filename": str(
Path("test/fixtures/templates/bad/core/mandatory_checks.yaml")
),
"Level": "Error",
"Location": {
"End": {"ColumnNumber": 13, "LineNumber": 35},
Expand All @@ -98,7 +109,9 @@ class TestDirectives(BaseCliTestCase):
},
},
{
"Filename": "test/fixtures/templates/bad/core/mandatory_checks.yaml",
"Filename": str(
Path("test/fixtures/templates/bad/core/mandatory_checks.yaml")
),
"Level": "Error",
"Location": {
"End": {"ColumnNumber": 15, "LineNumber": 37},
Expand All @@ -120,7 +133,9 @@ class TestDirectives(BaseCliTestCase):
},
},
{
"Filename": "test/fixtures/templates/bad/core/mandatory_checks.yaml",
"Filename": str(
Path("test/fixtures/templates/bad/core/mandatory_checks.yaml")
),
"Level": "Error",
"Location": {
"End": {"ColumnNumber": 18, "LineNumber": 13},
Expand All @@ -141,7 +156,9 @@ class TestDirectives(BaseCliTestCase):
},
},
{
"Filename": "test/fixtures/templates/bad/core/mandatory_checks.yaml",
"Filename": str(
Path("test/fixtures/templates/bad/core/mandatory_checks.yaml")
),
"Level": "Error",
"Location": {
"End": {"ColumnNumber": 16, "LineNumber": 19},
Expand Down
3 changes: 2 additions & 1 deletion test/unit/module/formatters/test_formatters.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import json
import sys
import xml.etree.ElementTree as ET
from pathlib import Path
from test.testlib.testcase import BaseTestCase

import jsonschema
Expand All @@ -27,7 +28,7 @@ class TestFormatters(BaseTestCase):
def setUp(self) -> None:
super().setUp()
cfnlint.core._reset_rule_cache()
self.filename = "test/fixtures/templates/bad/formatters.yaml"
self.filename = str(Path("test/fixtures/templates/bad/formatters.yaml"))
self.results = [
Match(
6,
Expand Down

0 comments on commit d625761

Please sign in to comment.