How to use test_page_source method in pytractor

Best Python code snippet using pytractor_python

test_admin.py

Source:test_admin.py Github

copy

Full Screen

1from django.contrib.auth.models import Group, Permission2from django.test import TestCase3from django.urls.base import reverse4from wagtail.core.models import Locale5from wagtail.tests.utils import WagtailTestUtils6from wagtail_localize.models import Translation7from .helpers import create_editor_user, create_snippet, create_test_page8class TestPageEditTranslateButton(TestCase, WagtailTestUtils):9 def setUp(self):10 self.editor_user = create_editor_user()11 self.locale_fr = Locale.objects.create(language_code="fr")12 self.locale_de = Locale.objects.create(language_code="de")13 self.client.force_login(self.editor_user)14 self.test_page, source = create_test_page(15 title="Test page",16 slug="test-page",17 test_charfield="Some test translatable content",18 )19 def test_translate_button_in_action_menu(self):20 resp = self.client.get(21 reverse("wagtailadmin_pages:edit", args=[self.test_page.pk])22 )23 self.assertContains(24 resp,25 f'<a class="button" href="/admin/localize/submit/page/{self.test_page.pk}/"><svg class="icon icon-site icon" aria-hidden="true" focusable="false"><use href="#icon-site"></use></svg>Translate this page</a>',26 )27 def test_translate_button_no_permission(self):28 group = Group.objects.get(name="Editors")29 group.permissions.remove(Permission.objects.get(codename="submit_translation"))30 resp = self.client.get(31 reverse("wagtailadmin_pages:edit", args=[self.test_page.pk])32 )33 self.assertNotContains(34 resp,35 f'<a class="button" href="/admin/localize/submit/page/{self.test_page.pk}/"><svg class="icon icon-site icon" aria-hidden="true" focusable="false"><use href="#icon-site"></use></svg>Translate this page</a>',36 )37 def test_translate_button_no_available_locales(self):38 self.locale_fr.delete()39 self.locale_de.delete()40 resp = self.client.get(41 reverse("wagtailadmin_pages:edit", args=[self.test_page.pk])42 )43 self.assertNotContains(44 resp,45 f'<a class="button" href="/admin/localize/submit/page/{self.test_page.pk}/"><svg class="icon icon-site icon" aria-hidden="true" focusable="false"><use href="#icon-site"></use></svg>Translate this page</a>',46 )47class TestPageEditSyncTranslationsButton(TestCase, WagtailTestUtils):48 def setUp(self):49 self.editor_user = create_editor_user()50 self.locale_fr = Locale.objects.create(language_code="fr")51 self.locale_de = Locale.objects.create(language_code="de")52 self.client.force_login(self.editor_user)53 self.test_page, self.test_page_source = create_test_page(54 title="Test page",55 slug="test-page",56 test_charfield="Some test translatable content",57 )58 # Create translations for test page59 Translation.objects.create(60 source=self.test_page_source, target_locale=self.locale_fr61 )62 Translation.objects.create(63 source=self.test_page_source, target_locale=self.locale_de64 )65 def test_sync_button_in_action_menu(self):66 resp = self.client.get(67 reverse("wagtailadmin_pages:edit", args=[self.test_page.pk])68 )69 self.assertContains(70 resp,71 f'<a class="button" href="/admin/localize/update/{self.test_page_source.pk}/"><svg class="icon icon-repeat icon" aria-hidden="true" focusable="false"><use href="#icon-repeat"></use></svg>Sync translated pages</a>',72 )73 def test_sync_button_no_permission(self):74 group = Group.objects.get(name="Editors")75 group.permissions.remove(Permission.objects.get(codename="submit_translation"))76 resp = self.client.get(77 reverse("wagtailadmin_pages:edit", args=[self.test_page.pk])78 )79 self.assertNotContains(80 resp,81 f'<a class="button" href="/admin/localize/update/{self.test_page_source.pk}/"><svg class="icon icon-repeat icon" aria-hidden="true" focusable="false"><use href="#icon-repeat"></use></svg>Sync translated pages</a>',82 )83 def test_sync_button_no_translations(self):84 self.locale_fr.delete()85 self.locale_de.delete()86 resp = self.client.get(87 reverse("wagtailadmin_pages:edit", args=[self.test_page.pk])88 )89 self.assertNotContains(90 resp,91 f'<a class="button" href="/admin/localize/update/{self.test_page_source.pk}/"><svg class="icon icon-repeat icon" aria-hidden="true" focusable="false"><use href="#icon-repeat"></use></svg>Sync translated pages</a>',92 )93class TestSnippetEditTranslateButton(TestCase, WagtailTestUtils):94 def setUp(self):95 group = Group.objects.get(name="Editors")96 # Add snippet permissions97 group.permissions.add(98 *Permission.objects.filter(99 codename__in=[100 "add_examplesnippet",101 "change_examplesnippet",102 "delete_examplesnippet",103 ]104 )105 )106 self.editor_user = create_editor_user()107 self.locale_fr = Locale.objects.create(language_code="fr")108 self.locale_de = Locale.objects.create(language_code="de")109 self.client.force_login(self.editor_user)110 self.test_snippet, source = create_snippet()111 def test_translate_button_in_action_menu(self):112 resp = self.client.get(113 reverse(114 "wagtailsnippets:edit",115 args=[116 "wagtail_localize_rws_languagecloud_test",117 "examplesnippet",118 self.test_snippet.pk,119 ],120 )121 )122 self.assertContains(123 resp,124 f'<a class="button" href="/admin/localize/submit/snippet/wagtail_localize_rws_languagecloud_test/examplesnippet/{self.test_snippet.pk}/"><svg class="icon icon-site icon" aria-hidden="true" focusable="false"><use href="#icon-site"></use></svg>Translate this snippet</a>',125 )126 def test_translate_button_no_permission(self):127 group = Group.objects.get(name="Editors")128 group.permissions.remove(Permission.objects.get(codename="submit_translation"))129 resp = self.client.get(130 reverse(131 "wagtailsnippets:edit",132 args=[133 "wagtail_localize_rws_languagecloud_test",134 "examplesnippet",135 self.test_snippet.pk,136 ],137 )138 )139 self.assertNotContains(140 resp,141 f'<a class="button" href="/admin/localize/submit/snippet/wagtail_localize_rws_languagecloud_test/examplesnippet/{self.test_snippet.pk}/"><svg class="icon icon-site icon" aria-hidden="true" focusable="false"><use href="#icon-site"></use></svg>Translate this snippet</a>',142 )143 def test_translate_button_no_available_locales(self):144 self.locale_fr.delete()145 self.locale_de.delete()146 resp = self.client.get(147 reverse(148 "wagtailsnippets:edit",149 args=[150 "wagtail_localize_rws_languagecloud_test",151 "examplesnippet",152 self.test_snippet.pk,153 ],154 )155 )156 self.assertNotContains(157 resp,158 f'<a class="button" href="/admin/localize/submit/snippet/wagtail_localize_rws_languagecloud_test/examplesnippet/{self.test_snippet.pk}/"><svg class="icon icon-site icon" aria-hidden="true" focusable="false"><use href="#icon-site"></use></svg>Translate this snippet</a>',159 )160class TestSnippetEditSyncTranslationsButton(TestCase, WagtailTestUtils):161 def setUp(self):162 group = Group.objects.get(name="Editors")163 # Add snippet permissions164 group.permissions.add(165 *Permission.objects.filter(166 codename__in=[167 "add_examplesnippet",168 "change_examplesnippet",169 "delete_examplesnippet",170 ]171 )172 )173 self.editor_user = create_editor_user()174 self.locale_fr = Locale.objects.create(language_code="fr")175 self.locale_de = Locale.objects.create(language_code="de")176 self.client.force_login(self.editor_user)177 self.test_snippet, self.test_snippet_source = create_snippet()178 # Create translations for test snippet179 Translation.objects.create(180 source=self.test_snippet_source, target_locale=self.locale_fr181 )182 Translation.objects.create(183 source=self.test_snippet_source, target_locale=self.locale_de184 )185 def test_sync_button_in_action_menu(self):186 resp = self.client.get(187 reverse(188 "wagtailsnippets:edit",189 args=[190 "wagtail_localize_rws_languagecloud_test",191 "examplesnippet",192 self.test_snippet.pk,193 ],194 )195 )196 self.assertContains(197 resp,198 f'<a class="button" href="/admin/localize/update/{self.test_snippet_source.pk}/"><svg class="icon icon-repeat icon" aria-hidden="true" focusable="false"><use href="#icon-repeat"></use></svg>Sync translated snippets</a>',199 )200 def test_sync_button_no_permission(self):201 group = Group.objects.get(name="Editors")202 group.permissions.remove(Permission.objects.get(codename="submit_translation"))203 resp = self.client.get(204 reverse(205 "wagtailsnippets:edit",206 args=[207 "wagtail_localize_rws_languagecloud_test",208 "examplesnippet",209 self.test_snippet.pk,210 ],211 )212 )213 self.assertNotContains(214 resp,215 f'<a class="button" href="/admin/localize/update/{self.test_snippet_source.pk}/"><svg class="icon icon-repeat icon" aria-hidden="true" focusable="false"><use href="#icon-repeat"></use></svg>Sync translated snippets</a>',216 )217 def test_sync_button_no_translations(self):218 self.locale_fr.delete()219 self.locale_de.delete()220 resp = self.client.get(221 reverse(222 "wagtailsnippets:edit",223 args=[224 "wagtail_localize_rws_languagecloud_test",225 "examplesnippet",226 self.test_snippet.pk,227 ],228 )229 )230 self.assertNotContains(231 resp,232 f'<a class="button" href="/admin/localize/update/{self.test_snippet_source.pk}/"><svg class="icon icon-repeat icon" aria-hidden="true" focusable="false"><use href="#icon-repeat"></use></svg>Sync translated snippets</a>',...

Full Screen

Full Screen

main-checkpoint.py

Source:main-checkpoint.py Github

copy

Full Screen

...9def fetch_page(page):10 print("Buscando a página...")11 page_source = requests.get(page)12 print("Testando o status da requisição...")13 test_page_source(page_source)14 return page_source15def test_page_source(ps):16 assert ps.status_code == 200, f"Erro ao buscar página. Código de Status {ps.status_code}. Verifique a conexão!"17 return 'Ok'18def extract_key_val(item):19 list_keys = [item.find('span', class_='car_name')['class'][0],20 item.find('span', class_='from')['class'][0],21 item.find('span', class_='mpg')['class'][0],22 item.find('span', class_='cylinders')['class'][0],23 item.find('span', class_='horsepower')['class'][0],24 item.find('span', class_='weight')['class'][0],25 item.find('span', class_='acceleration')['class'][0]]26 list_vals = [item.find('span', class_='car_name').text,27 item.find('span', class_='from').text,28 item.find('span', class_='mpg').text,29 item.find('span', class_='cylinders').text,...

Full Screen

Full Screen

main.py

Source:main.py Github

copy

Full Screen

...9def fetch_page(page):10 print("Buscando a página...")11 page_source = requests.get(page)12 print("Testando o status da requisição...")13 test_page_source(page_source)14 return page_source15def test_page_source(ps):16 assert ps.status_code == 200, f"Erro ao buscar página. Código de Status {ps.status_code}. Verifique a conexão!"17 return 'Ok'18def extract_key_val(item):19 list_keys = [item.find('span', class_='car_name')['class'][0],20 item.find('span', class_='from')['class'][0],21 item.find('span', class_='mpg')['class'][0],22 item.find('span', class_='cylinders')['class'][0],23 item.find('span', class_='horsepower')['class'][0],24 item.find('span', class_='weight')['class'][0],25 item.find('span', class_='acceleration')['class'][0]]26 list_vals = [item.find('span', class_='car_name').text,27 item.find('span', class_='from').text,28 item.find('span', class_='mpg').text,29 item.find('span', class_='cylinders').text,...

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