How to use get_page_size method in avocado

Best Python code snippet using avocado_python

widget.py

Source:widget.py Github

copy

Full Screen

...15 self.selectable = True16 def update(self, draw_select=True, to_display=[]):17 if not self.visible:18 return19 page_size = self.get_page_size()20 self.win.erase()21 self.draw_box()22 off = self.page * page_size23 width = self.win.getmaxyx()[1] - 224 self.title.draw_to_win(self.win, 0, 1, width)25 if not to_display and self.source:26 to_display = self.get_content(off, page_size + off)27 if len(to_display) > page_size:28 to_display = to_display[:page_size]29 for i, s in enumerate(to_display):30 if self.selectable and i + off == self.selected and draw_select:31 s.set_attr(curses.A_STANDOUT)32 s.draw_to_win(self.win, i + 1, 1, width)33 self.win.noutrefresh()34 def clear(self, refresh=True):35 self.win.clear()36 if refresh:37 self.win.refresh()38 def toggle_visible(self):39 self.visible = not self.visible40 self.clear()41 def select(self, direction):42 if not self.selectable:43 return44 off = self.get_page_size() * self.page45 if direction == Directions.UP:46 self.selected = max(0, self.selected - 1)47 if self.selected < off:48 self.page -= 149 elif direction == Directions.DOWN:50 self.selected += 151 if self.selected > self.source.get_max_index():52 self.selected -= 153 if self.selected >= off + self.get_page_size():54 self.page += 155 def get_selected(self):56 return self.source.get_at_index(self.selected)57 def jump_to_selection(self):58 self.selected = self.source.get_current_index()59 page_size = self.get_page_size()60 while self.page * page_size + page_size > self.selected:61 self.page -= 162 while self.page * page_size + page_size < self.selected:63 self.page += 164 def get_page_size(self):65 return self.win.getmaxyx()[0] - 266 def get_content(self, start, end):67 content = self.source.get_item_list(start, end)68 return [CurseString(str(c)) for c in content]69 def next_page(self):70 if self.selected + self.get_page_size() <= self.source.get_max_index():71 self.page += 172 self.selected = self.selected + self.get_page_size()73 def prev_page(self):74 page_incr = max(0, self.page - 1) - self.page75 self.page += page_incr76 self.selected += self.get_page_size() * page_incr77 def get_next_selectable_neighbour(self, direction):78 next = None79 match direction:80 case PanelDirections.UP:81 next = self.below_of82 case PanelDirections.DOWN:83 next = self.above_of84 case PanelDirections.LEFT:85 next = self.right_to86 case PanelDirections.RIGHT:87 next = self.left_to88 if next and next[0].selectable:89 return next[0]90 elif next:...

Full Screen

Full Screen

test_page_size.py

Source:test_page_size.py Github

copy

Full Screen

...9 error_message = "The entered page size ({}) is invalid"10 def test_integer_page_size_field(self):11 """ Verify that page_size is set to 100 if int 100 is given in the config """12 expected_value = 10013 actual_value = get_page_size(get_config(100), DEFAULT_PAGE_SIZE)14 15 self.assertEqual(actual_value, expected_value)16 17 def test_float_page_size_field(self):18 """ Verify that exception is raised with proper error message, if float 100.05 is given in the config """19 with self.assertRaises(Exception) as err:20 get_page_size(get_config(100.05), DEFAULT_PAGE_SIZE)21 self.assertEqual(str(err.exception), self.error_message.format(100.05))22 def test_zero_int_page_size_field(self):23 """ Verify that exception is raised with proper error message, if 0 is given in the config """24 with self.assertRaises(Exception) as err:25 get_page_size(get_config(0), DEFAULT_PAGE_SIZE)26 self.assertEqual(str(err.exception), self.error_message.format(0))27 def test_empty_string_page_size_field(self):28 """ Verify that page_size is set to DEFAULT_PAGE_SIZE if empty string is given in the config """29 expected_value = DEFAULT_PAGE_SIZE30 actual_value = get_page_size(get_config(""), DEFAULT_PAGE_SIZE)31 self.assertEqual(actual_value, expected_value)32 def test_string_page_size_field(self):33 """ Verify that page_size is set to 100 if string "100" is given in the config """34 expected_value = 10035 actual_value = get_page_size(get_config("100"), DEFAULT_PAGE_SIZE)36 self.assertEqual(actual_value, expected_value)37 def test_invalid_string_page_size_field(self):38 """ Verify that exception is raised with proper error message, if invalid string is given in the config """39 with self.assertRaises(Exception) as err:40 get_page_size(get_config("dg%#"), DEFAULT_PAGE_SIZE)41 self.assertEqual(str(err.exception), self.error_message.format("dg%#"))42 def test_zero_float_page_size_field(self):43 """ Verify that exception is raised with proper error message, if 0.0 is given in the config """44 with self.assertRaises(Exception) as err:45 get_page_size(get_config(0.0), DEFAULT_PAGE_SIZE)46 self.assertEqual(str(err.exception), self.error_message.format(0.0))47 def test_negative_int_page_size_field(self):48 """ Verify that exception is raised with proper error message, if negative int is given in the config """49 with self.assertRaises(Exception) as err:50 get_page_size(get_config(-10), DEFAULT_PAGE_SIZE)51 self.assertEqual(str(err.exception), self.error_message.format(-10))52 def test_negative_float_page_size_field(self):53 """ Verify that exception is raised with proper error message, if negative float is given in the config """54 with self.assertRaises(Exception) as err:55 get_page_size(get_config(-10.5), DEFAULT_PAGE_SIZE)...

Full Screen

Full Screen

base.py

Source:base.py Github

copy

Full Screen

1class ParentPosition:2 def __init__(self, adj):3 self.adj = adj4 def is_parent_scrollable(self):5 page_size = self.adj.get_page_size()6 upper = self.adj.get_upper()7 lower = self.adj.get_lower()8 return upper - lower > page_size9 def is_parent_at_top(self):10 value = self.adj.get_value()11 lower = self.adj.get_lower()12 is_at_top = (value == lower)13 return is_at_top14 def is_parent_at_bottom(self):15 page_size = self.adj.get_page_size()16 value = self.adj.get_value()17 upper = self.adj.get_upper()18 is_at_bottom = (value + page_size == upper)19 return is_at_bottom20 def is_parent_scrolled(self):21 is_at_top = self._is_parent_at_top()22 is_at_bottom = self._is_parent_at_bottom()23 return not is_at_top and not is_at_bottom24 def is_parent_large(self):25 page_size = self.adj.get_page_size()26 upper = self.adj.get_upper()27 lower = self.adj.get_lower()28 return 2*page_size < upper - lower29 def is_parent_distant_from_top(self):30 value = self.adj.get_value()31 page_size = self.adj.get_page_size()32 lower = self.adj.get_lower()33 distance_from_top = value - lower34 return distance_from_top >= 0.5*page_size35 def is_parent_distant_from_bottom(self):36 value = self.adj.get_value()37 page_size = self.adj.get_page_size()38 upper = self.adj.get_upper()39 distance_from_bottom = upper - (value + page_size)...

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 avocado 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