Skip to content

Commit

Permalink
Fix artefact driver test.
Browse files Browse the repository at this point in the history
The reason for the failing test was that the CLI parameters are generated at parse-time. Since the test modified the available choices of such an option, we need to reload the driver module for that change to take effect at the CLI level.
  • Loading branch information
boehmseb committed Jan 10, 2024
1 parent 6fe7894 commit 9ed2424
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions tests/tools/test_driver_artefacts.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
"""Test artefacts config tool."""
import traceback
import importlib
import unittest

from click.testing import CliRunner

import varats.tools.driver_artefacts as driver_artefacts
from tests.helper_utils import run_in_test_environment, UnitTestFixtures
from varats.data.discover_reports import initialize_reports
from varats.paper.paper_config import get_paper_config, load_paper_config
from varats.paper_mgmt.artefacts import Artefact, load_artefacts
from varats.plots.discover_plots import initialize_plots
from varats.tables.discover_tables import initialize_tables
from varats.tools import driver_artefacts
from varats.utils.settings import vara_cfg


Expand All @@ -32,6 +32,7 @@ def test_artefacts_generate(self) -> None:
# setup config
vara_cfg()['paper_config']['current_config'] = "test_artefacts_driver"
load_paper_config()
importlib.reload(driver_artefacts)
artefacts = load_artefacts(get_paper_config()).artefacts
base_output_dir = Artefact.base_output_dir()

Expand Down Expand Up @@ -59,8 +60,9 @@ def test_artefacts_list(self) -> None:
# setup config
vara_cfg()['paper_config']['current_config'] = "test_artefacts_driver"
load_paper_config()
importlib.reload(driver_artefacts)

# vara-art generate
# vara-art list
runner = CliRunner()
result = runner.invoke(driver_artefacts.main, ["list"])
self.assertEqual(0, result.exit_code, result.exception)
Expand All @@ -76,6 +78,16 @@ def test_artefacts_show(self) -> None:
# setup config
vara_cfg()['paper_config']['current_config'] = "test_artefacts_driver"
load_paper_config()
importlib.reload(driver_artefacts)

# vara-art list
runner = CliRunner()
result = runner.invoke(driver_artefacts.main, ["list"])
self.assertEqual(0, result.exit_code, result.exception)
self.assertEqual(
"Paper Config Overview [plot]\nCorrelation Table [table]\n"
"CS Overview (xz) [plot]\nRepo Churn (all) [plot]\n", result.stdout
)

expected = r"""Artefact 'Paper Config Overview':
artefact_type: plot
Expand All @@ -91,7 +103,7 @@ def test_artefacts_show(self) -> None:
"""

# vara-art generate
# vara-art show
runner = CliRunner()
result = runner.invoke(
driver_artefacts.main, ["show", "Paper Config Overview"]
Expand Down

0 comments on commit 9ed2424

Please sign in to comment.