Skip to content

Commit

Permalink
Add tests for calculate json output
Browse files Browse the repository at this point in the history
  • Loading branch information
andremralves committed Sep 11, 2024
1 parent 6a51fcb commit c1b179f
Show file tree
Hide file tree
Showing 2 changed files with 83 additions and 0 deletions.
52 changes: 52 additions & 0 deletions tests/unit/data/calc_msgram_exp_github_output.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
[
{
"repository": [
{
"key": "repository",
"value": "fga-eps-mds-2024.1-MeasureSoftGram-DOC"
}
],
"version": [
{
"key": "version",
"value": "28-07-2024-00-00"
}
],
"measures": [
{
"key": "team_throughput",
"value": 0.0
},
{
"key": "ci_feedback_time",
"value": 0.03225806451612903
}
],
"subcharacteristics": [
{
"key": "maturity",
"value": 0.03225806451612903
},
{
"key": "functional_completeness",
"value": 0.0
}
],
"characteristics": [
{
"key": "reliability",
"value": 0.03225806451612903
},
{
"key": "functional_suitability",
"value": 0.0
}
],
"tsqmi": [
{
"key": "tsqmi",
"value": 0.023147764246074717
}
]
}
]
31 changes: 31 additions & 0 deletions tests/unit/test_calculate.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from io import StringIO
from pathlib import Path
from unittest.mock import patch
import filecmp

import pytest

Expand Down Expand Up @@ -361,3 +362,33 @@ def test_calculate_csv_output():

shutil.rmtree(config_dirpath)
shutil.rmtree(extract_dirpath)


def test_calculate_json_output():
config_dirpath = tempfile.mkdtemp()
extract_dirpath = tempfile.mkdtemp()

shutil.copy("tests/unit/data/msgram.json", f"{config_dirpath}/msgram.json")

extracted_file_name = "github_fga-eps-mds-2024.1-MeasureSoftGram-DOC-28-07-2024-00-00-22-extracted.metrics"
shutil.copy(
f"tests/unit/data/{extracted_file_name}",
f"{extract_dirpath}/{extracted_file_name}",
)

args = {
"input_format": "github",
"output_format": "json",
"config_path": Path(config_dirpath),
"extracted_path": Path(extract_dirpath + f"/{extracted_file_name}"),
}

command_calculate(args)

output_path = Path(f"{config_dirpath}/calc_msgram.json")
expected_output = Path("tests/unit/data/calc_msgram_exp_github_output.json")
assert output_path.stat().st_size > 0
assert filecmp.cmp(output_path, expected_output, shallow=False)

shutil.rmtree(config_dirpath)
shutil.rmtree(extract_dirpath)

0 comments on commit c1b179f

Please sign in to comment.