code: def test_repo_with_plots(
      tmp_dir, scm, dvc, capsys, run_copy_metrics, repo_with_plots
  ):
      repo_state = repo_with_plots()
  
      image_v1, linear_v1, confusion_v1, confusion_props = next(
          repo_state
      )
  
      html_path, json_result, split_json_result = call(capsys)
      html_result = extract_vega_specs(
          html_path, ["linear.json", "confusion.json"]
      )
  
      assert "errors" not in json_result
      assert "errors" not in split_json_result
  
      json_data = json_result["data"]
      split_json_data = split_json_result["data"]
  
      assert json_data["linear.json"][0]["content"]["data"][
          "values"
      ] == _update_datapoints(
          linear_v1,
          {
              REVISION: "workspace",
          },
      )
      assert html_result["linear.json"]["data"][
          "values"
      ] == _update_datapoints(
          linear_v1,
          {
              REVISION: "workspace",
          },
      )
      assert json_data["confusion.json"][0]["content"]["data"][
          "values"
      ] == _update_datapoints(
          confusion_v1,
          {
              REVISION: "workspace",
          },
      )
      assert html_result["confusion.json"]["data"][
          "values"
      ] == _update_datapoints(
          confusion_v1,
          {
              REVISION: "workspace",
          },
      )
      verify_image(
          tmp_dir,
          "workspace",
          "image.png",
          image_v1,
          html_path,
          json_data,
      )
  
      for plot, title, x_label, y_label in [
          ("linear.json", "linear", "x", "y"),
          ("confusion.json", "confusion matrix", "predicted", "actual"),
      ]:
          verify_vega(
              "workspace",
              html_result[plot],
              json_data[plot],
              split_json_data[plot],
              title,
              x_label,
              y_label,
          )
  
      verify_vega_props("confusion.json", json_data, **confusion_props)
  
      image_v2, linear_v2, confusion_v2, confusion_props = next(
          repo_state
      )
  
      html_path, json_result, split_json_result = call(
          capsys, subcommand="diff"
      )
      html_result = extract_vega_specs(
          html_path, ["linear.json", "confusion.json"]
      )
  
      assert "errors" not in json_result
      assert "errors" not in split_json_result
  
      json_data = json_result["data"]
      split_json_data = split_json_result["data"]
  
      verify_image(
          tmp_dir,
          "workspace",
          "image.png",
          image_v2,
          html_path,
          json_data,
      )
      verify_image(
          tmp_dir, "HEAD", "image.png", image_v1, html_path, json_data
      )
  
      for plot, title, x_label, y_label in [
          ("linear.json", "linear", "x", "y"),
          ("confusion.json", "confusion matrix", "predicted", "actual"),
      ]:
          verify_vega(
              ["HEAD", "workspace"],
              html_result[plot],
              json_data[plot],
              split_json_data[plot],
              title,
              x_label,
              y_label,
          )
      verify_vega_props("confusion.json", json_data, **confusion_props)
      path = tmp_dir / "subdir"
      path.mkdir()
      with path.chdir():
          html_path, json_result, split_json_result = call(
              capsys, subcommand="diff"
          )
          html_result = extract_vega_specs(
              html_path,
              ["../linear.json", "../confusion.json"],
          )
  
          assert "errors" not in json_result
          assert "errors" not in split_json_result
  
          json_data = json_result["data"]
          split_json_data = split_json_result["data"]
          assert json_data["../linear.json"][0]["content"]["data"][
              "values"
          ] == _update_datapoints(
              linear_v2,
              {
                  REVISION: "workspace",
              },
          ) + _update_datapoints(
              linear_v1,
              {
                  REVISION: "HEAD",
              },
          )
          assert html_result["../linear.json"]["data"][
              "values"
          ] == _update_datapoints(
              linear_v2,
              {
                  REVISION: "workspace",
              },
          ) + _update_datapoints(
              linear_v1,
              {
                  REVISION: "HEAD",
              },
          )
          assert json_data["../confusion.json"][0]["content"]["data"][
              "values"
          ] == _update_datapoints(
              confusion_v2,
              {
                  REVISION: "workspace",
              },
          ) + _update_datapoints(
              confusion_v1,
              {
                  REVISION: "HEAD",
              },
          )
          assert html_result["../confusion.json"]["data"][
              "values"
          ] == _update_datapoints(
              confusion_v2,
              {
                  REVISION: "workspace",
              },
          ) + _update_datapoints(
              confusion_v1,
              {
                  REVISION: "HEAD",
              },
          )
  
          for plot, title, x_label, y_label in [
              ("../linear.json", "linear", "x", "y"),
              (
                  "../confusion.json",
                  "confusion matrix",
                  "predicted",
                  "actual",
              ),
          ]:
              verify_vega(
                  ["HEAD", "workspace"],
                  html_result[plot],
                  json_data[plot],
                  split_json_data[plot],
                  title,
                  x_label,
                  y_label,
              )
          verify_image(
              path,
              "workspace",
              "../image.png",
              image_v2,
              html_path,
              json_data,
          )
          verify_image(
              path,
              "HEAD",
              "../image.png",
              image_v1,
              html_path,
              json_data,
          )
  
imports: import json
  import os
  from copy import deepcopy
  from typing import Dict, List
  from urllib.parse import urlparse
  from urllib.request import url2pathname
  import dpath
  import pytest
  from bs4 import BeautifulSoup
  from funcy import first
  from dvc.cli import main
  from dvc.render import ANCHOR_DEFINITIONS, FILENAME, REVISION
label_desc: Use image node_id 10 for calling a global function with example usage: test_repo_with_plots(tmp_dir, scm, dvc, capsys, run_copy_metrics, repo_with_plots) without return types