How to use _set_return_value method in autotest

Best Python code snippet using autotest_python

test_trade_data.py

Source:test_trade_data.py Github

copy

Full Screen

...16 self.price = 20017 self.volume = 10018 pass19 def test_get_trade_data_all_symbols_found(self, mock_function):20 self._set_return_value(mock_function, ETH)21 data = TradeData.get_data_for_all_symbols()22 self.assertTrue(TradeData.get_current_trade_data(data, ETH, TradeData.PRICE), self.price)23 self.assertTrue(TradeData.get_current_trade_data(data, ETH, TradeData.VOLUME), self.volume)24 25 def test_get_trade_data_all_symbols_not_found(self, mock_function):26 self._set_return_value(mock_function, XXX)27 self.assertIsNone(TradeData.get_current_trade_data(28 TradeData.get_data_for_all_symbols(), XXX, TradeData.PRICE), self.price)29 def test_get_number_of_rows_not_empty(self, mock_function):30 self._set_return_value(mock_function, ETH)31 data = TradeData.get_data_for_all_symbols()32 data = data.append(TradeData.get_data_for_all_symbols())33 self.assertTrue(TradeData.get_number_of_rows(data, ETH) == 2)34 35 def test_get_number_of_rows_empty(self, mock_function):36 self._set_return_value(mock_function, ETH)37 self.assertTrue(TradeData.get_number_of_rows(TradeData.get_data_for_all_symbols(), LTC) == 0)38 def test_get_penultimate_trade_data(self, mock_function):39 self._set_return_value(mock_function, ETH)40 self.price = 100041 self.volume = 200042 data = TradeData.get_data_for_all_symbols()43 self.price = 200044 self.volume = 400045 data = data.append(TradeData.get_data_for_all_symbols())46 penultimate_price = self.price47 penultimate_volume = self.volume48 self.price = 2000049 self.volume = 4000050 data = data.append(TradeData.get_data_for_all_symbols())51 self.assertTrue(TradeData.get_penultimate_trade_data(data, ETH, TradeData.VOLUME), 52 penultimate_volume)53 self.assertTrue(TradeData.get_penultimate_trade_data(data, ETH, TradeData.PRICE), 54 penultimate_price)55 def test_get_penultimate_trade_data(self, mock_function):56 self._set_return_value(mock_function, ETH)57 self.price = 100058 self.volume = 200059 data = TradeData.get_data_for_all_symbols()60 self.price = 200061 self.volume = 400062 data = data.append(TradeData.get_data_for_all_symbols())63 n_price = self.price64 n_volume = self.volume65 self.price = 2000066 self.volume = 4000067 data = data.append(TradeData.get_data_for_all_symbols())68 self.price = 10000069 self.volume = 200000070 data = data.append(TradeData.get_data_for_all_symbols())71 self.assertTrue(TradeData.get_current_minus_n_trade_data(data, ETH, TradeData.VOLUME, 3), 72 n_volume)73 self.assertTrue(TradeData.get_current_minus_n_trade_data(data, ETH, TradeData.PRICE, 3), 74 n_price)75 def _set_return_value(self, _mock_function, ticker):76 """ This private method sets the return value of the mock function that is called repeatedly77 for every test method78 Args:79 mock_function(MagicMock): the mock function80 ticker_symbol(str): the ticker to be acted upon81 """82 _mock_function.return_value = [{TradeClient().VOLUME: self.volume, 83 TradeClient().PRICE: self.price, ...

Full Screen

Full Screen

sharedmock.py

Source:sharedmock.py Github

copy

Full Screen

...9from pprint import pformat10class SharedMockObj:11 def __init__(self):12 self.call_parameters = []13 self._set_return_value(None)14 def __call__(self, *args, **kwargs):15 self.call_parameters.append({'args': args, 'kwargs': kwargs})16 return self.return_value17 def _get_call_parameters(self):18 return self.call_parameters19 def _set_return_value(self, value):20 self.return_value = value21 def call_count(self):22 return len(self.call_parameters)23class SharedMockProxy(BaseProxy):24 _exposed_ = ['__call__',25 '_get_call_parameters',26 '_set_return_value',27 '_set_return_value_empty_dict',28 'assert_has_calls',29 'call_count'30 ]31 def __setattr__(self, name, value):32 if name == 'return_value':33 self._callmethod('_set_return_value', args=(value,))...

Full Screen

Full Screen

mock.py

Source:mock.py Github

copy

Full Screen

...3from sharedmock.asserters import assert_calls_equal, assert_calls_equal_unsorted4class SharedMockObj:5 def __init__(self):6 self.call_parameters = []7 self._set_return_value(None)8 def __call__(self, *args, **kwargs):9 self.call_parameters.append({'args': args, 'kwargs': kwargs})10 return self.return_value11 def _get_call_parameters(self):12 return self.call_parameters13 def _set_return_value(self, value):14 self.return_value = value15 def call_count(self):16 return len(self.call_parameters)17class SharedMockProxy(BaseProxy):18 _exposed_ = ['__call__',19 '_get_call_parameters',20 '_set_return_value',21 '_set_return_value_empty_dict',22 'assert_has_calls',23 'call_count'24 ]25 def __setattr__(self, name, value):26 if name == 'return_value':27 self._callmethod('_set_return_value', args=(value,))...

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