def check_rates_in_widget(self, from_currency, to_currency): current_buy_rate = self.get_current_buy_rate() current_sell_rate = self.get_current_sell_rate() expected_rates = ApiHelper().get_current_buy_and_sell_values_from_api( from_currency, to_currency) expected_rates[0] = str(expected_rates[0]).replace(".", ",") expected_rates[1] = str(expected_rates[1]).replace(".", ",") assert expected_rates == [current_buy_rate, current_sell_rate]
def convert_currency_by_api_rates(self, ammount, from_currency, to_currency): rates = ApiHelper().get_exchange_rate_from_api(from_currency, to_currency) buy_rates = float(rates['buyValue']) sell_rates = float(rates['sellValue']) scale = int(rates['scale']) if from_currency == "RUB": return round(float(ammount) * scale / sell_rates, 2) else: return round(float(ammount) * scale * buy_rates, 2)
def setUpClass(cls): cls.maxDiff = None cls.gateAlreadyExists = ServiceAlreadyExists().message cls.notFound = NotFound().message cls.gateNameNotValid = ServiceNameNotValid().message cls.gateStateNotValid = GateStateNotValid().message cls.environmentNotFound = EnvironmentNotFound( "non_existing_environment").message cls.ticketNotFound = TicketNotFound().message cls.jsonStructureError = JsonStructureError().message cls.api_helper = ApiHelper(environment) # TODO fix environment? cls.database_helper = DatabaseHelper( environment) # TODO fix environment? cls.testdata_helper = TestDataHelper(cls.api_helper) cls.keys_develop_state = ['environments', 'develop', 'state']