From 1343a32586055c95a9a1ebdba10ddb29c2bf5ee8 Mon Sep 17 00:00:00 2001 From: Scott Samet <thesamets@frontier.com> Date: Thu, 1 Aug 2024 11:56:17 -0500 Subject: [PATCH] testing seek alpha api --- seeking_alpha_api.py | 1 + test_seeking_alpha_api.py | 30 +++++++++++++++++++++++------- 2 files changed, 24 insertions(+), 7 deletions(-) diff --git a/seeking_alpha_api.py b/seeking_alpha_api.py index 86311e2..0e1fc6d 100644 --- a/seeking_alpha_api.py +++ b/seeking_alpha_api.py @@ -17,6 +17,7 @@ def ia_get_summary_data(ticker_list): } response = requests.get(url, headers=headers, params=querystring) response_json = response.json() + return response_json # def ia_get_profile(ticker_list): diff --git a/test_seeking_alpha_api.py b/test_seeking_alpha_api.py index abcf968..fcad832 100644 --- a/test_seeking_alpha_api.py +++ b/test_seeking_alpha_api.py @@ -1,18 +1,34 @@ import pytest +import json +import pprint from seeking_alpha_api import get_seeking_alpha_api_data_dicts from seeking_alpha_api import ia_get_momentum from seeking_alpha_api import ia_get_profile from seeking_alpha_api import ia_get_summary_data - +# +''' +****** Test ability to gather lists of Ticker symbols (note, api usage and data limits apply.) +** Leaving commented out due to external API +''' # def test_get_data_dicts_tc1(): # ticker_list, ticker_dict_list = get_seeking_alpha_api_data_dicts() # assert (len(ticker_list))-2 == len(ticker_dict_list) - -# def test_get_data_dicts_tc2(): -# assert square_root(16) == 4 - -# def test_get_data_dicts_tc3(): -# assert square_root(16) == 4 +# +''' +**** Test External API Resources, api usage and data limits apply. +''' +def test_get_summary_data_tc2(): + json_obj = ia_get_summary_data(["SPY"]) + # print(f'*** JSON:{json_obj}') + assert json_obj['data'][0]['id'] == "SPY" +# +def test_get_profile_data_tc3(): + json_obj = ia_get_profile(["SPY"]) + assert json_obj['data'][0]['id'] == "SPY" +# +def test_get_momentum_data_tc4(): + json_obj = ia_get_momentum(["SPY"]) + assert json_obj['data'][0]['id'] == "SPY" # def test_add_tc2(): # with pytest.raises(ValueError): -- GitLab