def test_data_flow(self, DictReader, CsvActionFactory):
        file = MagicMock()
        row = MagicMock()
        row_provider = MagicMock()
        DictReader.return_value = row_provider
        row_provider.__iter__.return_value = [row]
        model_mock = MagicMock()
        external_system_mock = MagicMock()
        action_mock = MagicMock()
        CsvActionFactory.return_value.from_dict.return_value = [action_mock]
        SyncFileAction.sync(external_system_mock, model_mock, file, False)
        DictReader.assert_called_with(file)
        CsvActionFactory.assert_called_with(model_mock, external_system_mock)

        CsvActionFactory.return_value.from_dict.assert_called_with(row)
        action_mock.execute.assert_called_once_with()
Esempio n. 2
0
    def test_data_flow(self, DictReader, CsvActionFactory):
        file = MagicMock()
        row = MagicMock()
        row_provider = MagicMock()
        DictReader.return_value = row_provider
        row_provider.__iter__.return_value = [row]
        model_mock = MagicMock()
        external_system_mock = MagicMock()
        action_mock = MagicMock()
        CsvActionFactory.return_value.from_dict.return_value = [action_mock]
        SyncFileAction.sync(external_system_mock, model_mock, file, False)
        DictReader.assert_called_with(file)
        CsvActionFactory.assert_called_with(model_mock, external_system_mock)

        CsvActionFactory.return_value.from_dict.assert_called_with(row)
        action_mock.execute.assert_called_once_with()
 def test_it_wraps_the_basic_policy_in_a_transaction_policy_if_configured(
         self, CsvActionFactory,
         BasicSyncPolicy, TransactionSyncPolicy):
     SyncFileAction.sync(MagicMock(), MagicMock(), MagicMock(), True)
     TransactionSyncPolicy.assert_called_with(BasicSyncPolicy.return_value)
     TransactionSyncPolicy.return_value.execute.assert_called_once_with()
Esempio n. 4
0
 def test_it_wraps_the_basic_policy_in_a_transaction_policy_if_configured(
         self, CsvActionFactory, BasicSyncPolicy, TransactionSyncPolicy):
     SyncFileAction.sync(MagicMock(), MagicMock(), MagicMock(), True)
     TransactionSyncPolicy.assert_called_with(BasicSyncPolicy.return_value)
     TransactionSyncPolicy.return_value.execute.assert_called_once_with()