How to use _get_rate method in autotest

Best Python code snippet using autotest_python

tests.py

Source:tests.py Github

copy

Full Screen

...20 self.assertEqual(len(retval), 1)21 a.assert_called_with(signal=test_signal, sender=None, hello="hello")22class TestRateLimitUtils(unittest.TestCase):23 def test_get_rate_1000_s(self):24 rate = ratelimit._get_rate("1000/s")25 self.assertEqual(rate, (1000, 1))26 def test_get_rate_1000_1s(self):27 rate = ratelimit._get_rate("1000/1s")28 self.assertEqual(rate, (1000, 1))29 def test_get_rate_1_5m(self):30 rate = ratelimit._get_rate("1/5m")31 self.assertEqual(rate, (1, 5 * 60))32 def test_get_rate_4_5h(self):33 rate = ratelimit._get_rate("4/5h")34 self.assertEqual(rate, (4, 5 * 60 * 60))35 def test_get_rate_20_2d(self):36 rate = ratelimit._get_rate("20/2d")37 self.assertEqual(rate, (20, 60 * 60 * 24 * 2))38 def test_not_a_rate(self):39 self.assertRaises(ValueError, ratelimit._get_rate, "1 every 2 seconds")40 def test_invalid_units(self):41 self.assertRaises(ValueError, ratelimit._get_rate, "1/5y")42 def test_invalid_freq(self):43 self.assertRaises(ValueError, ratelimit._get_rate, "a/5s")44 def test_invalid_period(self):45 self.assertRaises(ValueError, ratelimit._get_rate, "1/zh")46class TestRateLimitEnforce(unittest.TestCase):47 def setUp(self):48 caches['default'].clear()49 def test_enforce(self):50 @ratelimit.enforce_rate_limit("1/10s")...

Full Screen

Full Screen

currencies.py

Source:currencies.py Github

copy

Full Screen

...24 dotenv.load_dotenv()25 self.MIN_MARKUP = int(environ.get('MIN_MARKUP'))26 self.MAX_MARKUP = int(environ.get('MAX_MARKUP'))27 self.attention_counter = 028 def _get_rate(self, currency_code: str) -> float:29 try:30 return self.exchange_rates[currency_code]31 except KeyError:32 raise Exception('Error: Currency code not found')33 def update(self):34 self.exchange_rates = self.client.update_currency_rates()35 def get_exchange_rate(self, from_currency: str, to_currency: str) -> float:36 if from_currency == 'USD':37 return self._get_rate(to_currency)38 elif to_currency == 'USD':39 return 1 / self._get_rate(from_currency)40 else:41 return self._get_rate(to_currency) / self._get_rate(from_currency)42 def compare_exchange_rates(self) -> None:43 shoper_rate = shoper.get_exchange_rate()44 global_rate = self.get_exchange_rate("EUR", "PLN")45 ints = int(floor(global_rate))46 decimals = int(round((global_rate - ints) * 100))47 markup = (shoper_rate / global_rate - 1) * 10048 if self.MIN_MARKUP <= markup <= self.MAX_MARKUP:49 return50 elif markup < self.MIN_MARKUP:51 self.notifier.notify('rate.low')52 self.notifier.speak(f'Euro po {ints},{decimals} zł. Podnieś kurs w sklepie!')53 else:54 self.notifier.notify('rate.high')55 self.notifier.speak(f'Euro po {ints},{decimals} zł. Obniż kurs w sklepie!')...

Full Screen

Full Screen

test_account_tax_rate.py

Source:test_account_tax_rate.py Github

copy

Full Screen

...5from .common import StopTestException, TestCommon6class TestAccountTaxRate(TestCommon):7 def test_compute_rate_date(self):8 """It should add the rate date."""9 rate = self._get_rate()10 self.assertEqual(rate.rate_date, fields.Date.today())11 def test_get_reference_models(self):12 """It should return a list with unknown contents."""13 self.assertIsInstance(14 self.env['account.tax.rate']._get_reference_models(),15 list,16 )17 def test_is_dirty_no_change(self):18 """It should return ``False`` when there are no changes."""19 self.assertFalse(self._get_rate().is_dirty())20 def test_is_dirty_not_today(self):21 """It should return ``True`` when the rate is not from today."""22 rate = self._get_rate()23 rate.rate_date = '2015-01-01'24 self.assertTrue(rate.is_dirty())25 def test_is_dirty_true_line(self):26 """It should return ``True`` when a line is updated."""27 rate = self._get_rate()28 rate.line_ids[0].quantity = rate.line_ids[0].quantity + 129 self.assertTrue(rate.is_dirty())30 def test_is_dirty_line_change_not_monitored(self):31 """It should return ``False`` when non-monitored field is changed."""32 rate = self._get_rate()33 rate.line_ids[0].name = 'This is a different name'34 self.assertFalse(rate.is_dirty())35 def test_get_rate_values(self):36 """It should return a dictionary."""37 invoice = self._create_invoice()38 self.assertIsInstance(39 self.env['account.tax.rate'].get_rate_values(invoice),40 dict,41 )42 def test_get_creates(self):43 """It should return a new rate if non-existent."""44 invoice = self.env['account.invoice'].search([], limit=1)45 self.assertTrue(46 self.env['account.tax.rate'].get(47 'account.invoice.tax.rate', invoice,48 ),49 )50 def test_get_existing(self):51 """It should return existing rates."""52 rate = self._get_rate()53 self.assertEqual(54 self.env['account.tax.rate'].get(55 'account.invoice.tax.rate', rate.reference,56 ),57 rate,58 )59 def test_get_no_write_when_not_dirty(self):60 """It should not attempt to write the rate if unchanged."""61 rate = self._get_rate()62 rate._patch_method('write', self._stop_test_mock())63 try:64 self.env['account.tax.rate'].get(65 'account.invoice.tax.rate', rate.reference,66 )67 finally:68 rate._revert_method('write')69 # If there isn't an exception, the test passed.70 self.assertTrue(True)71 def test_get_writes_when_dirty(self):72 """It should write to the rate if dirty."""73 rate = self._get_rate()74 rate.line_ids[0].quantity = rate.line_ids[0].quantity + 175 rate._patch_method('write', self._stop_test_mock())76 passed = False77 try:78 self.env['account.tax.rate'].get(79 'account.invoice.tax.rate', rate.reference,80 )81 except StopTestException:82 # If there is an exception, the test passed.83 passed = True84 finally:85 rate._revert_method('write')...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run autotest automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful