Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_parse_price_without_currency_symbol(self):
price = '11,33 USD'
decimal_price = utils.parse_price(price)
self.assertEquals(decimal_price, decimal.Decimal('11.33'))
def test_parse_price_without_decimal_separator(self):
price = '2137 CZK'
decimal_price = utils.parse_price(price)
self.assertEquals(decimal_price, decimal.Decimal('2137'))
def test_parse_price_with_currency_symbol(self):
price = '$11.33 USD'
decimal_price = utils.parse_price(price)
self.assertEquals(decimal_price, decimal.Decimal('11.33'))
def test_parse_price_without_space(self):
price = '21,37zł'
decimal_price = utils.parse_price(price)
self.assertEqual(decimal_price, decimal.Decimal('21.37'))
def get_wallet_balance(self, convert_to_decimal: bool = True) -> Union[str, decimal.Decimal]:
url = SteamUrl.STORE_URL + '/account/history/'
response = self._session.get(url)
response_soup = bs4.BeautifulSoup(response.text, "html.parser")
balance = response_soup.find(id='header_wallet_balance').string
if convert_to_decimal:
return parse_price(balance)
else:
return balance