Team Ai
Apppublic

mlnsio/text2sql

sourceHugging Faceapache-2.0updated 3y agoView on Hugging Face
0likes
test_datapipeline.py39 linesDownload Raw Back to tests
1from django.test import TestCase2from unittest.mock import patch, Mock3 4# from data_pipeline.api_helper import MFList5 6 7# class TestMFListExtract(TestCase):8 9#     @patch('requests.get')10#     def test_extract_successful_response(self, mock_get):11#         # Mock a successful response from the Morningstar API12#         mock_get.return_value = Mock(status_code=200, json=lambda: {'rows': [{'legalName': 'Test Fund 1', 'isin': '123456789012', 'secId': 'MST01234'}]})13 14#         # Create an instance of the MFList class15#         mf_list = MFList()16 17#         # Call the extract method18#         mf_list.extract()19 20#         # Assert that the API response was set21#         self.assertIsNotNone(mf_list.api_response)22 23#         # Assert that the transformed data contains the extracted fund information24#         self.assertEqual(mf_list.transformed_data, [{'fund_name': 'Test Fund 1', 'isin_number': '123456789012', 'security_id': 'MST01234'}])25 26#     @patch('requests.get')27#     def test_extract_unsuccessful_response(self, mock_get):28#         # Mock an unsuccessful response from the Morningstar API29#         mock_get.return_value = Mock(status_code=500, json=lambda: {'error': 'Internal Server Error'})30 31#         # Create an instance of the MFList class32#         mf_list = MFList()33 34#         # Call the extract method35#         mf_list.extract()36 37#         # Assert that the API response was set38#         self.assertIsNone(mf_list.api_response)39