Best Python code snippet using fMBT_python
nco.py
Source: nco.py
1# -*- coding: utf-8 -*-2import tools3####################################################################################4nco_EmailAddress = '''5<%(email_address_uri)s> a nco:EmailAddress;6 nco:emailAddress "%(email_address)s".7'''8def generateEmailAddress(index):9 me = 'nco#EmailAddress'10 email_address = 'given%d.family%d@domain%d.com' % (index % 1000,index % 1000,index % 1000)11 email_address_uri = 'mailto:' + email_address12 tools.addItem( me, email_address_uri, nco_EmailAddress % locals() )13####################################################################################14nco_Contact_Email = '''15<%(emailcontact_uri)s> a nco:Contact;16 nco:fullname "%(emailcontact_name_given)s %(emailcontact_name_family)s";17 nco:nickname "%(emailcontact_nickname)s" ;18 nco:hasEmailAddress %(emailcontact_email_address_uri)s .19'''20def generateContactEmail(index):21 me = 'nco#ContactEmail'22 emailcontact_uri = 'urn:contact:email%d' % index23 emailcontact_name_given = 'Given%d' % (index % 1000)24 emailcontact_name_family = 'Family%d' % (index % 1000)25 emailcontact_nickname = 'Nickname%d' % (index % 1000)26 emailcontact_email_address_uri= '<%s>' % tools.getLastUri( 'nco#EmailAddress' )27 tools.addItem( me, emailcontact_uri, nco_Contact_Email % locals() )28####################################################################################29nco_PhoneNumber = '''30<%(phonenumber_uri)s> a nco:CellPhoneNumber;31 nco:phoneNumber "%(phonenumber)s".32'''33def generatePhoneNumber(index):34 me = 'nco#PhoneNumber'35 phonenumber = '+%d-555-%08d' %(index, index)36 phonenumber_uri = 'tel:' + phonenumber37 tools.addItem( me, phonenumber_uri, nco_PhoneNumber % locals() )38####################################################################################39nco_Contact_Call = '''40<%(callcontact_uri)s> a nco:Contact;41 nco:fullname "%(callcontact_name_given)s %(callcontact_name_family)s";42 nco:nickname "%(callcontact_nickname)s" ;43 nco:hasPhoneNumber %(callcontact_phonenumber_uri)s .44'''45def generateContactCall(index):46 me = 'nco#ContactCall'47 callcontact_uri = 'urn:contact:call%d' % index48 callcontact_name_given = 'Given%d' % (index % 1000)49 callcontact_name_family = 'Family%d' % (index % 1000)50 callcontact_nickname = 'Nickname%d' % (index % 1000)51 callcontact_phonenumber_uri = '<%s>' % tools.getLastUri( 'nco#PhoneNumber' )52 tools.addItem( me, callcontact_uri, nco_Contact_Call % locals() )53####################################################################################54nco_PostalAddress = '''55<%(postal_address_uri)s> a nco:PostalAddress;56 nco:country "%(postal_address_country)s" ;57 nco:pobox "%(postal_address_pobox)s" ;58 nco:region "%(postal_address_region)s" ;59 nco:postalcode "%(postal_address_postal_code)s" ;60 nco:locality "%(postal_address_city)s" ;61 nco:streetAddress "%(postal_address_street)s" .62'''63def generatePostalAddress(index):64 me = 'nco#PostalAddress'65 postal_address_uri = 'urn:pa:%d' % index66 postal_address_country = 'Country %d' % (index % 1000)67 postal_address_locality = 'Locality %d' % (index % 1000)68 postal_address_pobox = str(index)69 postal_address_region = 'Region %d' % (index % 1000)70 postal_address_postal_code = '%05d' % (index % 100000)71 postal_address_city = 'City %d' % (index % 1000)72 postal_address_street = 'Demo Street %d' % (index % 100)73 tools.addItem( me, postal_address_uri, nco_PostalAddress % locals() )74####################################################################################75nco_IMAddress = '''76<%(im_address_uri)s> a nco:IMAddress;77 nco:imID "%(im_address_imid)s" ;78 nco:imCapability %(im_address_capability)s .79'''80def generateIMAddress(index):81 me = 'nco#IMAddress'82 im_address_uri = 'urn:ima:%d' % index83 im_address_imid = 'IM ID %d' % (index % 1000)84 im_address_capability = '<%s>' % ('nco:im-capability-text-chat', 'nco:im-capability-audio-calls') [ index %2 ]85 tools.addItem( me, im_address_uri, nco_IMAddress % locals() )86####################################################################################87nco_Contact_IM = '''88<%(imcontact_uri)s> a nco:Contact;89 nco:fullname "%(imcontact_name_given)s %(imcontact_name_family)s";90 nco:nickname "%(imcontact_nickname)s" ;91 nco:hasIMAddress %(imcontact_imaddress_uri)s .92'''93def generateContactIM(index):94 me = 'nco#ContactIM'95 imcontact_uri = 'urn:contact:im%d' % index96 imcontact_name_given = 'Given%d' % (index % 1000)97 imcontact_name_family = 'Family%d' % (index % 1000)98 imcontact_nickname = 'Nickname%d' % (index % 1000)99 imcontact_imaddress_uri = '<%s>' % tools.getLastUri( 'nco#IMAddress' )100 tools.addItem( me, imcontact_uri, nco_Contact_IM % locals() )101####################################################################################102nco_PersonContact = '''103<%(contact_uri)s:home> a nco:Affiliation;104 nco:hasEmailAddress %(email_address_uri)s ;105 nco:hasPhoneNumber %(phonenumber_uri)s ;106 nco:hasPostalAddress %(postal_address_uri)s ;107 nco:hasIMAddress %(im_address_uri)s .108<%(contact_uri)s> a nco:PersonContact;109 nco:fullname "%(contact_name_given)s %(contact_name_family)s";110 nco:nameGiven "%(contact_name_given)s";111 nco:nameFamily "%(contact_name_family)s";112 nco:nameAdditional "%(contact_name_additional)s" ;113 nco:nickname "%(contact_nickname)s" ;114 nco:nameHonorificPrefix "%(contact_honorific_prefix)s" ;115 nco:nameHonorificSuffix "%(contact_honorific_suffix)s" ;116 nco:birthDate "%(contact_birth_date)s" ;117 nco:gender %(contact_gender)s ;118 nco:contactUID "%(contact_uid)s" ;119 nco:note "%(contact_note)s" ;120 nie:contentCreated "%(contact_created)s" ;121 nie:contentLastModified "%(contact_modified)s" ;122 nco:hasAffiliation <%(contact_uri)s:home> .123'''124def generatePersonContact(index):125 me = 'nco#PersonContact'126 contact_uri = 'urn:uid:%d' % index127 contact_name_given = 'Given%d' % (index % 1000)128 contact_name_family = 'Family%d' % (index % 1000)129 contact_name_additional = 'Additional%d' % (index % 1000)130 contact_nickname = 'Nickname%d' % (index % 1000)131 contact_honorific_prefix = ('Sir', 'Master') [index % 2]132 contact_honorific_suffix = ('PhD', 'Deceased') [index % 2]133 contact_birth_date = '%d-%02d-%02dT%02d:%02d:%02dZ' % (1900 + (index % 100), (index % 12) + 1, (index % 25) + 1, (index % 12) + 1, (index % 12) + 1, (index % 12) + 1)134 contact_gender = '<%s>' % ('nco:gender-female', 'nco:gender-female') [index % 2]135 contact_uid = 'uid:contact:%d' % index136 contact_note = 'Note number %d' % index137 email_address_uri = '<%s>' % tools.getLastUri( 'nco#EmailAddress' )138 phonenumber_uri = '<%s>' % tools.getLastUri( 'nco#PhoneNumber' )139 postal_address_uri = '<%s>' % tools.getLastUri( 'nco#PostalAddress' )140 im_address_uri = '<%s>' % tools.getLastUri( 'nco#IMAddress' )141 contact_created = '%d-%02d-%02dT%02d:%02d:%02dZ' % (1950 + (index % 50), (index % 12) + 1, (index % 25) + 1, (index % 12) + 1, (index % 12) + 1, (index % 12) + 1)142 contact_modified = '%d-%02d-%02dT%02d:%02d:%02dZ' % (1960 + (index % 40), (index % 12) + 1, (index % 25) + 1, (index % 12) + 1, (index % 12) + 1, (index % 12) + 1)...
Check out the latest blogs from LambdaTest on this topic:
Collecting and examining data from multiple sources can be a tedious process. The digital world is constantly evolving. To stay competitive in this fast-paced environment, businesses must frequently test their products and services. While it’s easy to collect raw data from multiple sources, it’s far more complex to interpret it properly.
Hola Testers! Hope you all had a great Thanksgiving weekend! To make this time more memorable, we at LambdaTest have something to offer you as a token of appreciation.
When I started writing tests with Cypress, I was always going to use the user interface to interact and change the application’s state when running tests.
So, now that the first installment of this two fold article has been published (hence you might have an idea of what Agile Testing is not in my opinion), I’ve started feeling the pressure to explain what Agile Testing actually means to me.
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!!