def test_read_file_from_gcs_json( self, mock_get_text_file, mock_base_client): """Test read_file_from_gcs for json.""" expected_dict = {"test": 1} mock_base_client.return_value = None mock_get_text_file.return_value = json.dumps(expected_dict) return_dict = file_loader._read_file_from_gcs('gs://fake/file.json') self.assertEqual(expected_dict, return_dict)
def test_read_file_from_gcs_yaml( self, mock_get_text_file, mock_base_client): """Test read_file_from_gcs for yaml.""" expected_dict = {"test": 1} mock_base_client.return_value = None mock_get_text_file.return_value = 'test: 1' return_dict = file_loader._read_file_from_gcs('gs://fake/file.yaml') self.assertEqual(expected_dict, return_dict)
def test_read_file_from_gcs_yaml(self, mock_default_credential): """Test read_file_from_gcs for yaml.""" mock_responses = [({ 'status': '200', 'content-range': '0-6/7' }, b'test: 1')] http_mocks.mock_http_response_sequence(mock_responses) expected_dict = {'test': 1} return_dict = file_loader._read_file_from_gcs('gs://fake/file.yaml') self.assertEqual(expected_dict, return_dict)
def test_read_file_from_gcs_json(self): """Test read_file_from_gcs for json.""" mock_responses = [({ 'status': '200', 'content-range': '0-10/11' }, b'{"test": 1}')] http_mocks.mock_http_response_sequence(mock_responses) expected_dict = {'test': 1} return_dict = file_loader._read_file_from_gcs('gs://fake/file.json') self.assertEqual(expected_dict, return_dict)