Skip to content

Commit

Permalink
new test for path
Browse files Browse the repository at this point in the history
  • Loading branch information
lizlouise1335 committed Jul 18, 2023
1 parent 323bb47 commit b9e7c81
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion tests/test_dataset_generator.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import unittest
from unittest import mock

import pandas as pd
from numpy.random import PCG64, Generator

from synthetic_data.dataset_generator import generate_dataset_by_class
Expand Down Expand Up @@ -59,3 +59,20 @@ def test_generate_custom_datasets(self):
)
self.assertEqual(4, len(df))
self.assertListEqual(list(df.columns), expected_columns)

@mock.patch("synthetic_data.dataset_generator.pd.DataFrame.to_csv")
def test_path_to_csv(self, to_csv):
columns_to_gen = [
{"generator": "integer"},
{"generator": "datetime"},
{"generator": "text"},
]
to_csv.return_value = "does_not_matter"
to_csv.side_effect = ValueError("Test successful")
with self.assertRaisesRegex(ValueError, "Test successful"):
generate_dataset_by_class(
self.rng,
columns_to_generate=columns_to_gen,
dataset_length=4,
path="testing_path",
)

0 comments on commit b9e7c81

Please sign in to comment.