You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

25 lines
825 B

  1. import unittest
  2. from unittest.mock import MagicMock
  3. import pandas as pd
  4. from pandas.testing import assert_frame_equal
  5. from data_export.pipeline.dataset import Dataset
  6. class TestDataset(unittest.TestCase):
  7. def setUp(self):
  8. example = MagicMock()
  9. example.to_dict.return_value = {"data": "example"}
  10. self.examples = MagicMock()
  11. self.examples.__iter__.return_value = [example]
  12. label = MagicMock()
  13. label.find_by.return_value = {"labels": ["label"]}
  14. self.labels = MagicMock()
  15. self.labels.__iter__.return_value = [label]
  16. def test_to_dataframe(self):
  17. dataset = Dataset(self.examples, self.labels)
  18. df = dataset.to_dataframe()
  19. expected = pd.DataFrame([{"data": "example", "labels": ["label"]}])
  20. assert_frame_equal(df, expected)