Best Python code snippet using websmith_python
test_views.py
Source:test_views.py
...12 casse_reelle = 20,13 observation = "Some text"14 )15 new.save()16 def test_fill_form(self):17 self.assertEqual(FormulaireCasse.objects.all().count(), 1)18 self.client.force_login(self.user)19 response = self.client.post(20 reverse("suiviproduction:submit", kwargs={"parametre": "casses_recues"}),21 data = {22 'casses_recues' : '10'23 }24 )25 self.assertEqual(FormulaireCasse.objects.all().count(), 2)26 def test_updates_form(self):27 form = FormulaireCasse.objects.get(id=1)28 self.assertEqual(form.casse_reelle, 20)29 self.client.force_login(self.user)30 response = self.client.post(31 reverse("suiviproduction:submit", kwargs={"parametre": "casse_reelle"}),32 data={33 'casse_reelle': '4',34 'element_id': "{}".format(form.id)35 })36 self.assertEqual(FormulaireCasse.objects.get(id=form.id).casse_reelle, 24)37class UpdateFormTest(TestCase):38 """ Test module for updating a form. """39 def setUp(self):40 self.user = User.objects.create(username="User1", user_role='Q', password="azerty50")41 self.form = ParametresPhysicoChimiques(42 controleur = self.user,43 chlore_libre = 0,44 chlore_total = 0,45 turbidite = 0,46 ph = 7,47 durete = 15,48 nitrate = 0,49 observation = "Some text"50 )51 self.form.save()52 def test_fill_form(self):53 self.assertEqual(ParametresPhysicoChimiques.objects.all().count(), 1)54 self.client.force_login(self.user)55 response = self.client.post(56 reverse("suiviqualite:submit", kwargs={"parametre": "physicochimique"}),57 data = {58 'chlore_libre' : 0,59 'chlore_total' : 0,60 'turbidite' : 0,61 'ph' : 7,62 'durete' : 15,63 'nitrate' : 0,64 'observation' : "Some text"65 }66 )67 self.assertEqual(ParametresPhysicoChimiques.objects.all().count(), 2)68 def test_updates_form(self):69 self.assertEqual(self.form.chlore_libre, 0)70 self.client.force_login(self.user)71 response = self.client.post(72 reverse("suiviqualite:submit", kwargs={"parametre": "physicochimique"}),73 data={74 'chlore_libre': 1,75 'chlore_total' : 1,76 'turbidite' : 0,77 'ph' : 7,78 'durete' : 15,79 'nitrate' : 0,80 'observation' : "Some text",81 'element_id': "{}".format(self.form.id)82 })83 self.assertEqual(ParametresPhysicoChimiques.objects.get(id=self.form.id).chlore_libre, 1)84class ProductionTest(TestCase):85 def setUp(self):86 self.user = User.objects.create(username="User1", user_role='P', password="azerty50")87 def test_fill_form(self):88 self.assertEqual(FormulaireProduction.objects.all().count(), 0)89 self.client.force_login(self.user)90 response = self.client.post(91 reverse("suiviproduction:submit", kwargs={"parametre": "production"}),92 data={93 'quart': 'Q1',94 'tickets' : 10,95 'sacs' : 32,96 'observation' : "Some text"97 })...
fill_form_test.py
Source:fill_form_test.py
1from pages.formPage import Form2from pages.homePage import Home3from test.conftest import browser, quit_browser, readData, old_browser4def test_fill_form(driver):5 form_page = Form(driver, config)6 home_page = Home(driver)7 # Given the form is displayed8 # home_page.load()9 home_page.verifyToolsQAPage()10 home_page.clickOnElements()11 form_page.clickOnForm()12 # When user fill the name, email and current address and click on submit13 form_page.fillName()14 form_page.fillEmail()15 form_page.fillCurrentAddress()16 form_page.clickSubmitButton()17 # Then system displays above the information that user has fill previously18 form_page.verify()19 """20 form_page.verifyNameIsDisplayed()21 form_page.verifyEmailIsDisplayed()22 form_page.verifyCurrentAddressIsDisplayed()23 """24config = readData()25driver = old_browser(config)26test_fill_form(driver)...
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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!