diff --git a/tests/data/discovery_fidelity_model.yaml b/tests/data/discovery_fidelity_model.yaml new file mode 100755 index 00000000000..86396dc954e --- /dev/null +++ b/tests/data/discovery_fidelity_model.yaml @@ -0,0 +1,2466 @@ +test_get_orders: + base_orders: + mock_fidelity_orders_html: | + + + + + + + + + + + + + + + + + + + + + + Stock Research - Fidelity + + + + + + + + + + + + + + + + + + Top Orders By Fidelity Customers + + + + + + + +
+ + + + +
+ + +
+ + +
+
+ + + + + +
+ + + + + + + + + + +
+ +
+ + + + + +
+
+ +
+

+
+ + +
+
+
+
+
+ + +
+ +
+ + + +
+
+ + + + +
+ +
+ + + +
+ +
+ +
+ + +
+ + + + + + +
+ + + +
+ +
+
+ +
+ + + + + + + + +
+ + + + + + Close + +
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + expected_header: "As of market close 03/29/21" + expected_orders: | + ,Symbol,Buy / Sell Ratio,Price Change,Company,# Buy Orders,# Sell Orders,Latest News + 0,TSLA,"71% Buys, 29% Sells",+8.29 (+1.3561%),TESLA INC,"16,267","6,675",BRIEF-Tesla Building New Tesla Semi Production Line At New Building Near Its Gigafactory Nevada Plant - Electrek + 1,GME,"65% Buys, 35% Sells",+15.58 (+8.5935%),GAMESTOP CORP,"8,441","4,621",GameStop appoints Amazon executive as chief growth officer + 2,HGEN,"49% Buys, 51% Sells",+0.63 (+2.9153%),HUMANIGEN INC,"6,072","6,427",BRIEF-Humanigen Inc Says Drew Initial $25.0 Million Term Loan Pursuant To Its Loan And Security Agreement With Hercules Capital Inc + 3,VIAC,"71% Buys, 29% Sells",+0.92 (+2.044%),VIACOMCBS INC,"8,277","3,313",Credit Suisse in firing line after Archegos losses + 4,PLTR,"83% Buys, 17% Sells",-0.06 (-0.2761%),PALANTIR TECHNOLOGIES INC,"8,051","1,615",Aviation startup Lilium to float in US via $3.3 bln SPAC deal + 5,SEAC,"49% Buys, 51% Sells",-0.6459 (-31.0529%),SEACHANGE INTERNATIONAL INC,"4,412","4,630",BRIEF-Seachange International Prices $19.1 Million Underwritten Public Offering Of Common Stock + 6,AAPL,"55% Buys, 45% Sells",-1.795 (-1.4787%),APPLE INC,"4,905","4,070","Google, U.S. government tangle over pre-trial document production" + 7,NIO,"69% Buys, 31% Sells",+1.79 (+5.0408%),NIO INC,"6,103","2,780",Form 6-K NIO Inc. For: Mar 26 + 8,AMC,"67% Buys, 33% Sells",-0.125 (-1.2077%),AMC ENTERTAINMENT HOLDINGS INC,"4,736","2,345","National CineMedia, Inc. Appoints Mark Zoradi to Its Board of Directors" + 9,HOFV,"49% Buys, 51% Sells",-1.191 (-17.6444%),HALL OF FAME RESORT & ENTERTAINMENT CO,"3,179","3,364","Hall of Fame Resort & Entertainment Company Unveils Cities, Team Names and Logos for the Hall Of Fantasy League" + 10,BIDU,"62% Buys, 38% Sells",+10.7843 (+5.2683%),BAIDU INC,"3,442","2,144","Form 6-K Baidu, Inc. For: Mar 30" + 11,BA,"54% Buys, 46% Sells",+1.3479 (+0.538%),BOEING CO,"2,740","2,340",US STOCKS-Wall St drops as tech stocks hit by spike in yields + 12,TQQQ,"53% Buys, 47% Sells",-2.18 (-2.4605%),PROSHARES ULTRAPRO QQQ,"2,632","2,373",Traders chase sky-high returns in leveraged exchange traded products + 13,UPC,"53% Buys, 47% Sells",-1.12 (-19.9643%),UNIVERSE PHARMACEUTICALS INC,"2,611","2,346",Form 6-K Universe Pharmaceuticals For: Mar 25 + 14,CCIV,"80% Buys, 20% Sells",+1.38 (+6.4637%),CHURCHILL CAPITAL IV CORP,"3,896",944,BRIEF-Lucid Motors Says Michael Bell Joining As Senior Vice President Of Digital + 15,RKT,"41% Buys, 59% Sells",+0.035 (+0.1471%),ROCKET COMPANIES INC,"1,954","2,810","Form 10-K Rocket Companies, Inc. For: Dec 31" + 16,ARKK,"75% Buys, 25% Sells",+2.16 (+1.943%),ARK INNOVATION ETF,"3,384","1,149",Cathie Wood's Ark expects Tesla stock to reach $3000 by 2025 + 17,AMZN,"53% Buys, 47% Sells",-26.40 (-0.8583%),AMAZONCOM INC,"2,392","2,137",Arm Ltd debuts new chip technology aimed at overtaking data centers + 18,RIOT,"53% Buys, 47% Sells",+1.931 (+4.0322%),RIOT BLOCKCHAIN INC,"2,209","1,933",Web Based Education Solutions to Remain Vital Post-Pandemic + 19,DKNG,"76% Buys, 24% Sells",+2.13 (+3.6598%),DRAFTKINGS INC,"3,131","1,006","BRIEF-Draftkings Acquires Vsin, Multi-Platform Sports Betting Broadcast And Content Company" + 20,TME,"65% Buys, 35% Sells",+0.558 (+2.7434%),TENCENT MUSIC ENTERTAINMENT GROUP,"2,612","1,418",Credit Suisse in firing line after Archegos losses + 21,SPY,"67% Buys, 33% Sells",-1.545 (-0.3904%),SPDR S&P 500 ETF TRUST,"2,619","1,285",Analysis: Debacle at Archegos throws excessive risk-taking into spotlight + 22,SQ,"76% Buys, 24% Sells",+3.41 (+1.6459%),SQUARE INC,"2,881",888,"Form 4 Square, Inc. For: Mar 23 Filed by: Ahuja Amrita" + 23,HCMC,"81% Buys, 19% Sells",-0.0001 (-8.333333%),HEALTHIER CHOICES MANAGEMENT CORP,"3,046",723,Healthier Choices Management Corp. Announces Re-Launching of its Vitamins and Supplements Online Store at TheVitaminStore.com + 24,AMD,"60% Buys, 40% Sells",-1.425 (-1.8473%),ADVANCED MICRO DEVICES INC,"2,143","1,439",Arm Ltd debuts new chip technology aimed at overtaking data centers + 25,DISCA,"77% Buys, 23% Sells",+1.67 (+4.0504%),DISCOVERY INC,"2,712",830,Credit Suisse in firing line after Archegos losses + 26,FB,"52% Buys, 48% Sells",-1.23 (-0.4229%),FACEBOOK INC,"1,818","1,684",Facebook's chief revenue officer to leave later this year + 27,MSFT,"65% Buys, 35% Sells",-3.48 (-1.4793%),MICROSOFT CORP,"2,242","1,218","Google, U.S. government tangle over pre-trial document production" + 28,MRNA,"72% Buys, 28% Sells",-5.83 (-4.7237%),MODERNA INC,"2,477",957,U.S. administers 147.6 mln doses of COVID-19 vaccines - CDC + 29,QQQ,"64% Buys, 36% Sells",-2.63 (-0.8325%),INVESCO QQQ TRUST SERIES 1,"2,167","1,221","Form N-CEN INVESCO QQQ TRUST, SERIE For: Dec 31" diff --git a/tests/test_discovery_fidelity_model.py b/tests/test_discovery_fidelity_model.py new file mode 100755 index 00000000000..027617df3b6 --- /dev/null +++ b/tests/test_discovery_fidelity_model.py @@ -0,0 +1,44 @@ +""" discovery/fidelity_model.py tests """ +import unittest +from unittest import mock + +# pylint: disable=unused-import +from gamestonk_terminal.test_helper import ( # noqa: F401 + parameterize_from_file, + pytest_generate_tests, +) + +from gamestonk_terminal.discovery.fidelity_model import get_orders + +assertions = unittest.TestCase("__init__") + + +class TestDiscoveryFidelityModel: + @mock.patch("gamestonk_terminal.discovery.fidelity_model.requests") + @parameterize_from_file( + "test_get_orders", + "../tests/data/discovery_fidelity_model.yaml", + ) + # pylint: disable=unused-argument + def test_get_orders( + self, + mock_requests_get, + mock_fidelity_orders_html, + expected_header, + expected_orders, + ): + mock_requests_get.get().text = mock_fidelity_orders_html + header, ret = get_orders() + + print("") + print(ret.to_csv()) + print("") + print(header) + + assertions.assertEqual.__self__.maxDiff = None + assertions.assertEqual( + header.replace("\r\n", "\n"), expected_header.replace("\r\n", "\n") + ) + assertions.assertEqual( + ret.to_csv().replace("\r\n", "\n"), expected_orders.replace("\r\n", "\n") + )