Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
fealho committed Nov 13, 2023
1 parent c1280ac commit 1d40139
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
2 changes: 1 addition & 1 deletion sdv/metadata/visualization.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def _replace_special_characters(string):


def visualize_graph(nodes, edges, filepath=None):
"""Plot metadata usign graphviz.
"""Plot metadata using graphviz.
Try to generate a plot using graphviz.
If a ``filepath`` is provided save the output into a file.
Expand Down
31 changes: 31 additions & 0 deletions tests/integration/metadata/test_visualization.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import pandas as pd

from sdv.metadata import MultiTableMetadata, SingleTableMetadata


def test_visualize_graph_for_single_table():
"""Test it runs when a column name contains `>`."""
# Setup
data = pd.DataFrame({'>': ['a', 'b', 'c']})
metadata = SingleTableMetadata()
metadata.detect_from_dataframe(data)

# Run
metadata.visualize()


def test_visualize_graph_for_multi_table():
"""Test it runs when a column name contains `>`."""
# Setup
data1 = pd.DataFrame({'>': ['a', 'b', 'c']})
data2 = pd.DataFrame({'>': ['a', 'b', 'c']})
tables = {'1': data1, '2': data2}
metadata = MultiTableMetadata()
metadata.detect_from_dataframes(tables)
metadata.update_column('1', '>', sdtype='id')
metadata.update_column('2', '>', sdtype='id')
metadata.set_primary_key('1', '>')
metadata.add_relationship('1', '2', '>', '>')

# Run
metadata.visualize()

0 comments on commit 1d40139

Please sign in to comment.