class TestObjectWriterFactory(unittest.TestCase):

    def setUp(self):
        compatibility_factory = mock.create_autospec(CompatibilityFactory).return_value
        self.object_writer_factory = ObjectWriterFactory(compatibility_factory)

    @mock.patch('xcrawler.files.writers.object_writer_factory.ObjectWriterCsv')
    def test_create_object_writer_csv(self, mock_object_writer_csv_class):
        mock_write_opener = mock.create_autospec(CompatibleWriteOpener).return_value
        mock_object_converter = mock.create_autospec(CompatibleObjectConverter).return_value
        mock_object_writer = mock.create_autospec(ObjectWriter).return_value
        self.object_writer_factory.compatibility_factory.create_compatible_write_opener.return_value = mock_write_opener
        self.object_writer_factory.compatibility_factory.create_compatible_object_converter.return_value = mock_object_converter
        mock_object_writer_csv_class.return_value = mock_object_writer
        result = self.object_writer_factory.create_object_writer_csv()
        mock_object_writer_csv_class.assert_called_once_with(mock_write_opener, mock_object_converter)
        self.assertEquals(result, mock_object_writer)
class TestObjectWriterFactory(unittest.TestCase):
    def setUp(self):
        compatibility_factory = mock.create_autospec(
            CompatibilityFactory).return_value
        self.object_writer_factory = ObjectWriterFactory(compatibility_factory)

    @mock.patch('xcrawler.files.writers.object_writer_factory.ObjectWriterCsv')
    def test_create_object_writer_csv(self, mock_object_writer_csv_class):
        mock_write_opener = mock.create_autospec(
            CompatibleWriteOpener).return_value
        mock_object_converter = mock.create_autospec(
            CompatibleObjectConverter).return_value
        mock_object_writer = mock.create_autospec(ObjectWriter).return_value
        self.object_writer_factory.compatibility_factory.create_compatible_write_opener.return_value = mock_write_opener
        self.object_writer_factory.compatibility_factory.create_compatible_object_converter.return_value = mock_object_converter
        mock_object_writer_csv_class.return_value = mock_object_writer
        result = self.object_writer_factory.create_object_writer_csv()
        mock_object_writer_csv_class.assert_called_once_with(
            mock_write_opener, mock_object_converter)
        self.assertEquals(result, mock_object_writer)
 def setUp(self):
     compatibility_factory = mock.create_autospec(
         CompatibilityFactory).return_value
     self.object_writer_factory = ObjectWriterFactory(compatibility_factory)
 def setUp(self):
     compatibility_factory = mock.create_autospec(CompatibilityFactory).return_value
     self.object_writer_factory = ObjectWriterFactory(compatibility_factory)
Exemple #5
0
 def __init__(self,
              filepath_splitter=FilePathSplitter(),
              object_writer_factory=ObjectWriterFactory()):
     self.filepath_splitter = filepath_splitter
     self.object_writer_factory = object_writer_factory