Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add test file for SDoE plot_utils.py #1125

Merged
merged 1 commit into from
Mar 28, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions foqus_lib/framework/sdoe/test/test_plot_utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#################################################################################
# FOQUS Copyright (c) 2012 - 2023, by the software owners: Oak Ridge Institute
# for Science and Education (ORISE), TRIAD National Security, LLC., Lawrence
# Livermore National Security, LLC., The Regents of the University of
# California, through Lawrence Berkeley National Laboratory, Battelle Memorial
# Institute, Pacific Northwest Division through Pacific Northwest National
# Laboratory, Carnegie Mellon University, West Virginia University, Boston
# University, the Trustees of Princeton University, The University of Texas at
# Austin, URS Energy & Construction, Inc., et al. All rights reserved.
#
# Please see the file LICENSE.md for full copyright and license information,
# respectively. This file is also available online at the URL
# "https://github.com/CCSI-Toolset/FOQUS".
#################################################################################
import pytest
from foqus_lib.framework.sdoe import plot_utils
from unittest import mock
from importlib import resources
from pathlib import Path


@mock.patch("foqus_lib.framework.sdoe.plot_utils.plt")
def test_plot(fake_plt: mock.MagicMock):

fake_fig = mock.MagicMock()
fake_axes = mock.MagicMock()
fake_plt.subplots.return_value = (fake_fig, fake_axes)
fname = "candidates_usf.csv"
copy_from_package(fname)
scatter_label = "something"

plot_utils.plot(fname=fname, scatter_label=scatter_label)

assert fake_plt.show.call_count > 0


def copy_from_package(file_name: str) -> None:
content = resources.read_text(__package__, file_name)
Path(file_name).write_text(content)