Best Python code snippet using SeleniumBase
Tkinter Miniproject.py
Source:Tkinter Miniproject.py
...74 datum.append(omgezet)75 omgezet = terugomzettenASCII(row['obdfpqo^qfbkrjjbo'])76 registratienummer.append(omgezet)77 return stalling, wachtwoorden, datum, registratienummer78def ophalen(invoerRegistratienummer, invoerWachtwoord):79 stalling, wachtwoorden, datum, registratienummer = ophalenGegevens()80 if invoerRegistratienummer in registratienummer:81 indexRegistratienummer = registratienummer.index(invoerRegistratienummer)82 if invoerWachtwoord in wachtwoorden[indexRegistratienummer]:83 del registratienummer[indexRegistratienummer]84 del wachtwoorden[indexRegistratienummer]85 stallingNieuw = []86 wachtwoordenNieuw = []87 datumNieuw = []88 registratienummerNieuw = []89 for regel in stalling:90 omgezet = omzettenASCII(regel)91 stallingNieuw.append(omgezet)92 for regel in wachtwoorden:...
Tkinter Miniproject v2.py
Source:Tkinter Miniproject v2.py
...74 datum.append(omgezet)75 omgezet = terugomzettenASCII(row['obdfpqo^qfbkrjjbo'])76 registratienummer.append(omgezet)77 return stalling, wachtwoorden, datum, registratienummer78def ophalen(invoerRegistratienummer, invoerWachtwoord):79 stalling, wachtwoorden, datum, registratienummer = ophalenGegevens()80 if invoerRegistratienummer in registratienummer:81 indexRegistratienummer = registratienummer.index(invoerRegistratienummer)82 if invoerWachtwoord in wachtwoorden[indexRegistratienummer]:83 del registratienummer[indexRegistratienummer]84 del wachtwoorden[indexRegistratienummer]85 stallingNieuw = []86 wachtwoordenNieuw = []87 datumNieuw = []88 registratienummerNieuw = []89 for regel in stalling:90 omgezet = omzettenASCII(regel)91 stallingNieuw.append(omgezet)92 for regel in wachtwoorden:...
test_service.py
Source:test_service.py
1import freezegun2from unittest import TestCase3from unittest.mock import patch, MagicMock4from gobmessage.hr.kvk.dataservice.service import KvkDataService5class TestKvkDataService(TestCase):6 @patch("gobmessage.hr.kvk.dataservice.service.HR_CERTFILE", 'certfile.crt')7 @patch("gobmessage.hr.kvk.dataservice.service.HR_KEYFILE", 'keyfile.key')8 @patch("gobmessage.hr.kvk.dataservice.service.KVK_DATASERVICE_ADDRESS", 'https://kvkdataservice')9 @patch("gobmessage.hr.kvk.dataservice.service.requests.Session")10 @patch("gobmessage.hr.kvk.dataservice.service.Transport")11 @patch("gobmessage.hr.kvk.dataservice.service.Client")12 @patch("gobmessage.hr.kvk.dataservice.service.KvkDataServiceBinarySignature")13 def test_get_client(self, mock_signature, mock_client, mock_transport, mock_session):14 service = KvkDataService()15 mock_client.return_value.service._binding_options = {}16 res = service._get_client()17 mock_transport.assert_called_with(session=mock_session())18 mock_signature.assert_called_with('keyfile.key', 'certfile.crt')19 mock_client.assert_called_with(20 'http://schemas.kvk.nl/contracts/kvk/dataservice/catalogus/2015/02/KVK-KvKDataservice.wsdl',21 wsse=mock_signature(),22 transport=mock_transport()23 )24 self.assertEqual(mock_client(), res)25 self.assertEqual('https://kvkdataservice', mock_client().service._binding_options['address'])26 self.assertEqual(('certfile.crt', 'keyfile.key'), mock_session().cert)27 def test_generate_reference(self):28 service = KvkDataService()29 with freezegun.freeze_time('2020-09-01 19:00:03'):30 self.assertEqual('GOB-20200901190003000000', service._generate_reference())31 def test_unpack_raw_elements(self):32 service = KvkDataService()33 a_elm = MagicMock()34 a_elm.tag = '{somenamespace}a'35 a_elm.text = 836 k_elm = MagicMock()37 k_elm.tag= '{thenamespace}k'38 k_elm.text = 5539 z_elm = MagicMock()40 z_elm.tag = '{http://some/other/namespace}z'41 z_elm.text = 942 in_dict = {43 'a': 1,44 'b': 2,45 'c': ['d', 'e', 'f'],46 'g': {47 'h': 3,48 'i': [{49 'j': 4,50 'k': 5,51 '_raw_elements': [k_elm],52 }, {53 'l': 6,54 'm': 7,55 }],56 'n': {57 'o': 10,58 'p': 11,59 }60 },61 '_raw_elements': [62 a_elm,63 z_elm,64 ]65 }66 expected = {67 'a': 8,68 'b': 2,69 'c': ['d', 'e', 'f'],70 'g': {71 'h': 3,72 'i': [{73 'j': 4,74 'k': 55,75 }, {76 'l': 6,77 'm': 7,78 }],79 'n': {80 'o': 10,81 'p': 11,82 }83 },84 'z': 9,85 }86 self.assertEqual(expected, service._unpack_raw_elements(in_dict))87 @patch("gobmessage.hr.kvk.dataservice.service.serialize_object")88 def test_make_request(self, mock_serialize):89 service = KvkDataService()90 service._get_client = MagicMock()91 service._generate_reference = MagicMock()92 service._unpack_raw_elements = MagicMock()93 res = service._make_request('someAction', kwarg1='value1', kwarg2='value2')94 service._get_client().service.someAction.assert_called_with(95 klantreferentie=service._generate_reference(),96 kwarg1='value1',97 kwarg2='value2'98 )99 mock_serialize.assert_called_with(service._get_client().service.someAction())100 service._unpack_raw_elements.assert_called_with(mock_serialize.return_value)101 self.assertEqual(service._unpack_raw_elements.return_value, res)102 res = service._make_request('someAction', raw_response=True, kwarg1='value1')103 self.assertEqual(service._get_client().service.someAction().text, res)104 def test_request_methods(self):105 testcases = [106 ('ophalen_inschrijving_by_kvk_nummer', 'ophalenInschrijving', 'kvkNummer'),107 ('ophalen_inschrijving_by_rsin', 'ophalenInschrijving', 'rsin'),108 ('ophalen_vestiging_by_vestigingsnummer', 'ophalenVestiging', 'vestigingsnummer'),109 ('ophalen_vestiging_by_kvk_nummer', 'ophalenVestiging', 'kvkNummer'),110 ('ophalen_vestiging_by_rsin', 'ophalenVestiging', 'rsin'),111 ]112 service = KvkDataService()113 service._make_request = MagicMock()114 for method_name, action, kwarg_name in testcases:115 method = getattr(service, method_name)116 res = method('some argument')117 # Assert make_request is called with the right kwarg name and the provided argument, and the result is118 # returned119 service._make_request.assert_called_with(action, raw_response=False, **{kwarg_name: 'some argument'})...
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!!