def test_get_company_name_ticker(): Company.__init__ = MagicMock(return_value=None) company = Company() company.response = '"label":"AMD (Advanced Micro Devices) Inc.", "symbol":"AMD"' company._get_company_name_ticker() assert company.name == "AMD (Advanced Micro Devices) Inc." assert company.ticker == "AMD"
def test_get_potential_profit(): Company.__init__ = MagicMock(return_value=None) company = Company() company.response = "high52weeks: 97.98, low52weeks: 36.75" company._get_potential_profit() profit = round(97.98 * 100 / 36.75 - 100, 2) assert company.poten_profit == f"{profit}%"
def test_get_price(): Company.__init__ = MagicMock(return_value=None) company = Company() company.dollar_rate = 100 company.response = '{"currentValue":91.81}' company._get_rub_price() assert company.price == 9181.0
def test_get_p_e_ratio(): Company.__init__ = MagicMock(return_value=None) company = Company() company.response = """class="snapshot__data-item"> 22.75, class="snapshot__data-item"> -35.66, class="snapshot__data-item"> 55.55, class="snapshot__data-item"> 33.33, class="snapshot__data-item"> 72.26""" company._get_p_e_ratio() assert company.p_e_ratio == "72.26"