How to use test_pagination method in SeleniumBase

Best Python code snippet using SeleniumBase

instances_pagination.py

Source:instances_pagination.py Github

copy

Full Screen

...62 assert_true(last_id < instance.id)63 def print_list(self, instances):64 print("Length = %d" % len(instances))65 print(",".join([instance.id for instance in instances]))66 def test_pagination(self, requested_limit, requested_marker,67 expected_length, expected_marker, expected_last_item):68 instances = self.dbaas.instances.list(limit=requested_limit,69 marker=requested_marker)70 marker = instances.next71 self.print_list(instances)72 # Better get as many as we asked for.73 assert_equal(len(instances), expected_length)74 # The last one should be roughly this one in the list.75 assert_equal(instances[-1].id, expected_last_item)76 # Because limit < count, the marker must be something.77 if expected_marker:78 assert_is_not(marker, None)79 assert_equal(marker, expected_marker)80 else:81 assert_is_none(marker)82 self.assert_instances_sorted_by_ids(instances)83@test(runs_after_groups=["dbaas.guest.shutdown"],84 groups=['dbaas.api.instances.pagination'])85class SimpleCreateAndDestroy(TestBase):86 """87 It turns out a big part of guaranteeing pagination works is to make sure88 we can create a big batch of instances and delete them without problems.89 Even in fake mode though its worth it to check this is the case.90 """91 max = 592 @before_class93 def set_up(self):94 """Create a ton of instances."""95 super(SimpleCreateAndDestroy, self).set_up()96 self.delete_instances()97 @test98 def spin_up(self):99 self.create_instances()100 @after_class(always_run=True)101 def tear_down(self):102 self.delete_instances()103@test(runs_after_groups=["dbaas.guest.shutdown"],104 groups=['dbaas.api.instances.pagination'])105class InstancePagination50(TestBase):106 max = 50107 @before_class108 def set_up(self):109 """Create a ton of instances."""110 super(InstancePagination50, self).set_up()111 self.delete_instances()112 self.create_instances()113 @after_class(always_run=True)114 def tear_down(self):115 """Tear down all instances."""116 self.delete_instances()117 @test118 def pagination_short(self):119 self.test_pagination(requested_limit=10, requested_marker=None,120 expected_length=10, expected_marker=self.ids[9],121 expected_last_item=self.ids[9])122 @test123 def pagination_default(self):124 self.test_pagination(requested_limit=None, requested_marker=None,125 expected_length=20, expected_marker=self.ids[19],126 expected_last_item=self.ids[19])127 @test128 def pagination_full(self):129 self.test_pagination(requested_limit=50, requested_marker=None,130 expected_length=20, expected_marker=self.ids[19],131 expected_last_item=self.ids[19])132@test(runs_after_groups=["dbaas.guest.shutdown"],133 groups=['dbaas.api.instances.pagination'])134class InstancePagination20(TestBase):135 max = 20136 @before_class137 def set_up(self):138 """Create a ton of instances."""139 super(InstancePagination20, self).set_up()140 self.delete_instances()141 self.create_instances()142 @after_class(always_run=True)143 def tear_down(self):144 """Tear down all instances."""145 self.delete_instances()146 @test147 def pagination_short(self):148 self.test_pagination(requested_limit=10, requested_marker=None,149 expected_length=10, expected_marker=self.ids[9],150 expected_last_item=self.ids[9])151 @test152 def pagination_default(self):153 self.test_pagination(requested_limit=None, requested_marker=None,154 expected_length=20, expected_marker=None,155 expected_last_item=self.ids[19])156 @test157 def pagination_full(self):158 self.test_pagination(requested_limit=20, requested_marker=None,159 expected_length=20, expected_marker=None,160 expected_last_item=self.ids[19])161 @test162 def pagination_overkill(self):163 self.test_pagination(requested_limit=30, requested_marker=None,164 expected_length=20, expected_marker=None,165 expected_last_item=self.ids[19])166 @test167 def pagination_last_half(self):168 self.test_pagination(requested_limit=10, requested_marker=self.ids[9],169 expected_length=10, expected_marker=None,170 expected_last_item=self.ids[19])171 @test172 def pagination_third_quarter(self):173 self.test_pagination(requested_limit=5, requested_marker=self.ids[9],174 expected_length=5, expected_marker=self.ids[14],175 expected_last_item=self.ids[14])176 @test177 def pagination_fourth_quarter(self):178 self.test_pagination(requested_limit=20, requested_marker=self.ids[14],179 expected_length=5, expected_marker=None,...

Full Screen

Full Screen

pagination_tests.py

Source:pagination_tests.py Github

copy

Full Screen

1"""Pagination Tests."""2from django.test import TestCase3import pagination4# 'search_result_json' dictionaries to be used in the tests.5SEARCH_RESULT_JSON_GOOD = {6 'total_primary_pages': 15,7 'current_page': 2,8 'prev_page_link_url': '\/a\/jobs\/list\/q-cook',9 'prev_page_link_text': '&lt; Previous',10 'next_page_link_url': '\/a\/jobs\/list\/q-cook\/pn-3',11 'next_page_link_text': 'Next &gt;',12 'prev_page_numbered_links': {13 '1': '\/a\/jobs\/list\/q-cook'14 },15 'next_page_numbered_links': {16 '3': '\/a\/jobs\/list\/q-cook\/pn-3',17 '4': '\/a\/jobs\/list\/q-cook\/pn-4',18 '5': '\/a\/jobs\/list\/q-cook\/pn-5',19 '6': '\/a\/jobs\/list\/q-cook\/pn-6',20 '7': '\/a\/jobs\/list\/q-cook\/pn-7',21 '8': '\/a\/jobs\/list\/q-cook\/pn-8',22 '9': '\/a\/jobs\/list\/q-cook\/pn-9',23 '10': '\/a\/jobs\/list\/q-cook\/pn-10'24 }25}26SEARCH_RESULT_JSON_NO_PREV_NEXT_LINKS = {27 'total_primary_pages': 15,28 'current_page': 2,29 'prev_page_link_url': '\/a\/jobs\/list\/q-cook',30 'prev_page_link_text': '&lt; Previous',31 'next_page_link_url': '\/a\/jobs\/list\/q-cook\/pn-3',32 'next_page_link_text': 'Next &gt;'33}34# Tests35class PaginationTestCase(TestCase):36 """Pagination TestCase."""37 # pylint: disable=R090438 def test_good_copying_of_basic_pagination_values(self):39 """Pagination attributes that are simply copied over should be good."""40 test_pagination = pagination.Pagination(search_result_json=SEARCH_RESULT_JSON_GOOD)41 self.assertEqual(test_pagination.num_pages, SEARCH_RESULT_JSON_GOOD['total_primary_pages'])42 self.assertEqual(test_pagination.current_page, SEARCH_RESULT_JSON_GOOD['current_page'])43 self.assertEqual(test_pagination.prev_page_link_url, SEARCH_RESULT_JSON_GOOD['prev_page_link_url'])44 self.assertEqual(test_pagination.prev_page_link_text, SEARCH_RESULT_JSON_GOOD['prev_page_link_text'])45 self.assertEqual(test_pagination.next_page_link_url, SEARCH_RESULT_JSON_GOOD['next_page_link_url'])46 self.assertEqual(test_pagination.next_page_link_text, SEARCH_RESULT_JSON_GOOD['next_page_link_text'])47 self.assertEqual(test_pagination.prev_page_numbered_links, SEARCH_RESULT_JSON_GOOD['prev_page_numbered_links'])48 self.assertEqual(test_pagination.next_page_numbered_links, SEARCH_RESULT_JSON_GOOD['next_page_numbered_links'])49 def test_empty_pagination(self):50 """Pagination attributes should have good default values when search_result_json is empty."""51 test_pagination = pagination.Pagination(search_result_json={})52 self.assertEqual(test_pagination.num_pages, 1)53 self.assertIsNone(test_pagination.current_page)54 self.assertIsNone(test_pagination.prev_page_link_url)55 self.assertIsNone(test_pagination.prev_page_link_text)56 self.assertIsNone(test_pagination.next_page_link_url)57 self.assertIsNone(test_pagination.next_page_link_text)58 self.assertIsNone(test_pagination.prev_page_numbered_links)59 self.assertIsNone(test_pagination.next_page_numbered_links)60 def test_no_next_or_prev_links(self):61 """Number of pages should be 1 when there are no previous or next links."""62 test_pagination = pagination.Pagination(search_result_json=SEARCH_RESULT_JSON_NO_PREV_NEXT_LINKS)...

Full Screen

Full Screen

test_pagination.py

Source:test_pagination.py Github

copy

Full Screen

1"""Deprecated import support. Auto-generated by import_shims/generate_shims.sh."""2# pylint: disable=redefined-builtin,wrong-import-position,wildcard-import,useless-suppression,line-too-long3from import_shims.warn import warn_deprecated_import4warn_deprecated_import('discussion.rest_api.tests.test_pagination', 'lms.djangoapps.discussion.rest_api.tests.test_pagination')...

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