def test_main_return_EX_DATAERR_exitcode_on_error(self, mock_get_args, mock_get_db_params, mock_ElastichsearchEngine): mock_get_db_params.return_value = Mock(), Mock() mock_es_manager = Mock() mock_ElastichsearchEngine.return_value = mock_es_manager mock_es_manager.put_mappings.side_effect = Exception('test error') res = main() self.assertEquals(res, os.EX_DATAERR)
def test_main_calls_esmanager_put_mappings_with_mappings(self, mock_get_args, mock_get_db_params, mock_ElastichsearchEngine): mock_get_db_params.return_value = Mock(), Mock() mock_es_manager = Mock() mock_ElastichsearchEngine.return_value = mock_es_manager res = main() self.assertEquals(res, os.EX_OK) mappings = db_mappings.get_mappings() mock_es_manager.put_mappings.assert_called_with(mappings)