Skip to content

Commit

Permalink
add test for writing two plots
Browse files Browse the repository at this point in the history
  • Loading branch information
PythonFZ committed Apr 12, 2022
1 parent 3f0dc25 commit 09846d6
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions tests/integration_tests/test_zn_plots.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import os
import pathlib
import shutil
import subprocess

Expand Down Expand Up @@ -66,3 +67,27 @@ def test_write_plots_value_error(proj_path):
def test_write_plots_type_error(proj_path):
with pytest.raises(TypeError):
WritePlotsWrongData().run_and_save()


class WriteTwoPlots(Node):
plots_a: pd.DataFrame = zn.plots()
plots_b: pd.DataFrame = zn.plots()

def run(self):
self.plots_a = pd.DataFrame({"value": [x for x in range(100)]})
self.plots_a.index.name = "my_index_a"

self.plots_b = pd.DataFrame({"value": [-x for x in range(100)]})
self.plots_b.index.name = "my_index_b"


def test_write_two_plots(proj_path):
WriteTwoPlots().write_graph(no_exec=False)
subprocess.check_call(["dvc", "plots", "show"])

wp = WriteTwoPlots.load()
assert wp.plots_a.index.name == "my_index_a"
assert wp.plots_b.index.name == "my_index_b"

assert pathlib.Path("nodes", "WriteTwoPlots", "plots_a.csv").exists()
assert pathlib.Path("nodes", "WriteTwoPlots", "plots_b.csv").exists()

0 comments on commit 09846d6

Please sign in to comment.