How to use set_host method in autotest

Best Python code snippet using autotest_python

test_messenger.py

Source:test_messenger.py Github

copy

Full Screen

...16 def test_environment(self):17 ntp_serv_daemon = NTPServer()18 ntp_serv = Computer()19 ntp_serv.get_service(ntp_serv_daemon)20 ntp_serv_daemon.set_host(ntp_serv)2122 msg_server_daemon = MSGServer()23 msg_server = Computer()24 msg_server.get_service(msg_server_daemon)25 msg_server_daemon.set_host(msg_server)26 msg_server_timer = Timer()27 msg_server.get_service(msg_server_timer)28 msg_server_timer.set_host(msg_server)2930 msg_server_rep1_daemon = MSGServerReplic()31 msg_server_rep1 = Computer()32 msg_server_rep1.get_service(msg_server_rep1_daemon)33 msg_server_rep1_daemon.set_host(msg_server_rep1)34 msg_server_rep1_timer = Timer()35 msg_server_rep1.get_service(msg_server_rep1_timer)36 msg_server_rep1_timer.set_host(msg_server_rep1)3738 msg_server_rep2_daemon = MSGServerReplic()39 msg_server_rep2 = Computer()40 msg_server_rep2.get_service(msg_server_rep2_daemon)41 msg_server_rep2_daemon.set_host(msg_server_rep2)42 msg_server_rep2_timer = Timer()43 msg_server_rep2.get_service(msg_server_rep2_timer)44 msg_server_rep2_timer.set_host(msg_server_rep2)4546 messenger1 = Messenger()47 messenger2 = Messenger()48 messenger1.set_msg_server("1.1.1.1")49 messenger2.set_msg_server("1.1.1.1")50 comp1 = Computer()51 comp2 = Computer()52 comp1.get_service(messenger1)53 comp2.get_service(messenger2)54 comp1_timer = Timer()55 comp2_timer = Timer()56 comp1.get_service(comp1_timer)57 comp2.get_service(comp2_timer)58 comp1_timer.set_host(comp1)59 comp2_timer.set_host(comp2)6061 net = Network()62 net.add_host(ntp_serv, "10.20.30.40")63 net.add_host(msg_server, "1.1.1.1")64 net.add_host(msg_server_rep1, "1.1.2.1")65 net.add_host(msg_server_rep2, "1.1.2.2")66 net.add_host(comp1, "172.10.1.1")67 net.add_host(comp2, "172.10.1.2")6869 net.set_ntp("10.20.30.40")70 msg_server_daemon.add_replic(msg_server_rep1_daemon)71 msg_server_daemon.add_replic(msg_server_rep2_daemon)7273 def test_send_msg(self):74 ntp_serv_daemon = NTPServer()75 ntp_serv = Computer()76 ntp_serv.get_service(ntp_serv_daemon)77 ntp_serv_daemon.set_host(ntp_serv)7879 msg_server_daemon = MSGServer()80 msg_server = Computer()81 msg_server.get_service(msg_server_daemon)82 msg_server_daemon.set_host(msg_server)83 msg_server_timer = Timer()84 msg_server.get_service(msg_server_timer)85 msg_server_timer.set_host(msg_server)8687 msg_server_rep1_daemon = MSGServerReplic()88 msg_server_rep1 = Computer()89 msg_server_rep1.get_service(msg_server_rep1_daemon)90 msg_server_rep1_daemon.set_host(msg_server_rep1)91 msg_server_rep1_timer = Timer()92 msg_server_rep1.get_service(msg_server_rep1_timer)93 msg_server_rep1_timer.set_host(msg_server_rep1)9495 msg_server_rep2_daemon = MSGServerReplic()96 msg_server_rep2 = Computer()97 msg_server_rep2.get_service(msg_server_rep2_daemon)98 msg_server_rep2_daemon.set_host(msg_server_rep2)99 msg_server_rep2_timer = Timer()100 msg_server_rep2.get_service(msg_server_rep2_timer)101 msg_server_rep2_timer.set_host(msg_server_rep2)102103 messenger1 = Messenger()104 messenger2 = Messenger()105 messenger1.set_msg_server("1.1.1.1")106 messenger2.set_msg_server("1.1.1.1")107 comp1 = Computer()108 comp2 = Computer()109 comp1.get_service(messenger1)110 comp2.get_service(messenger2)111 messenger1.set_host(comp1)112 messenger2.set_host(comp2)113 comp1_timer = Timer()114 comp2_timer = Timer()115 comp1.get_service(comp1_timer)116 comp2.get_service(comp2_timer)117 comp1_timer.set_host(comp1)118 comp2_timer.set_host(comp2)119120 net = Network()121 net.add_host(ntp_serv, "10.20.30.40")122 net.add_host(msg_server, "1.1.1.1")123 net.add_host(msg_server_rep1, "1.1.2.1")124 net.add_host(msg_server_rep2, "1.1.2.2")125 net.add_host(comp1, "172.10.1.1")126 net.add_host(comp2, "172.10.1.2")127128 net.set_ntp("10.20.30.40")129 msg_server_daemon.add_replic(msg_server_rep1_daemon)130 msg_server_daemon.add_replic(msg_server_rep2_daemon)131132 comp1.services["Messenger"].send_msg("172.10.1.2", "Hello")133 result = comp2.services["Messenger"].db.get_messages_num()134 self.assertEqual(result, 1)135136 def test_send_msg_and_read_last_msg(self):137 ntp_serv_daemon = NTPServer()138 ntp_serv = Computer()139 ntp_serv.get_service(ntp_serv_daemon)140 ntp_serv_daemon.set_host(ntp_serv)141142 msg_server_daemon = MSGServer()143 msg_server = Computer()144 msg_server.get_service(msg_server_daemon)145 msg_server_daemon.set_host(msg_server)146 msg_server_timer = Timer()147 msg_server.get_service(msg_server_timer)148 msg_server_timer.set_host(msg_server)149150 msg_server_rep1_daemon = MSGServerReplic()151 msg_server_rep1 = Computer()152 msg_server_rep1.get_service(msg_server_rep1_daemon)153 msg_server_rep1_daemon.set_host(msg_server_rep1)154 msg_server_rep1_timer = Timer()155 msg_server_rep1.get_service(msg_server_rep1_timer)156 msg_server_rep1_timer.set_host(msg_server_rep1)157158 msg_server_rep2_daemon = MSGServerReplic()159 msg_server_rep2 = Computer()160 msg_server_rep2.get_service(msg_server_rep2_daemon)161 msg_server_rep2_daemon.set_host(msg_server_rep2)162 msg_server_rep2_timer = Timer()163 msg_server_rep2.get_service(msg_server_rep2_timer)164 msg_server_rep2_timer.set_host(msg_server_rep2)165166 messenger1 = Messenger()167 messenger2 = Messenger()168 messenger1.set_msg_server("1.1.1.1")169 messenger2.set_msg_server("1.1.1.1")170 comp1 = Computer()171 comp2 = Computer()172 comp1.get_service(messenger1)173 comp2.get_service(messenger2)174 messenger1.set_host(comp1)175 messenger2.set_host(comp2)176 comp1_timer = Timer()177 comp2_timer = Timer()178 comp1.get_service(comp1_timer)179 comp2.get_service(comp2_timer)180 comp1_timer.set_host(comp1)181 comp2_timer.set_host(comp2)182183 net = Network()184 net.add_host(ntp_serv, "10.20.30.40")185 net.add_host(msg_server, "1.1.1.1")186 net.add_host(msg_server_rep1, "1.1.2.1")187 net.add_host(msg_server_rep2, "1.1.2.2")188 net.add_host(comp1, "172.10.1.1")189 net.add_host(comp2, "172.10.1.2")190191 net.set_ntp("10.20.30.40")192 msg_server_daemon.add_replic(msg_server_rep1_daemon)193 msg_server_daemon.add_replic(msg_server_rep2_daemon)194195 comp1.services["Messenger"].send_msg("172.10.1.2", "Hello")196 result = comp2.services["Messenger"].db.db[comp2.services["Messenger"].db.get_messages_num()-1].get_msg()197 self.assertEqual(result, "Hello")198199 def test_send_msg_and_download_history(self):200 ntp_serv_daemon = NTPServer()201 ntp_serv = Computer()202 ntp_serv.get_service(ntp_serv_daemon)203 ntp_serv_daemon.set_host(ntp_serv)204205 msg_server_daemon = MSGServer()206 msg_server = Computer()207 msg_server.get_service(msg_server_daemon)208 msg_server_daemon.set_host(msg_server)209 msg_server_timer = Timer()210 msg_server.get_service(msg_server_timer)211 msg_server_timer.set_host(msg_server)212213 msg_server_rep1_daemon = MSGServerReplic()214 msg_server_rep1 = Computer()215 msg_server_rep1.get_service(msg_server_rep1_daemon)216 msg_server_rep1_daemon.set_host(msg_server_rep1)217 msg_server_rep1_timer = Timer()218 msg_server_rep1.get_service(msg_server_rep1_timer)219 msg_server_rep1_timer.set_host(msg_server_rep1)220221 msg_server_rep2_daemon = MSGServerReplic()222 msg_server_rep2 = Computer()223 msg_server_rep2.get_service(msg_server_rep2_daemon)224 msg_server_rep2_daemon.set_host(msg_server_rep2)225 msg_server_rep2_timer = Timer()226 msg_server_rep2.get_service(msg_server_rep2_timer)227 msg_server_rep2_timer.set_host(msg_server_rep2)228229 messenger1 = Messenger()230 messenger2 = Messenger()231 messenger1.set_msg_server("1.1.1.1")232 messenger2.set_msg_server("1.1.1.1")233 comp1 = Computer()234 comp2 = Computer()235 comp1.get_service(messenger1)236 comp2.get_service(messenger2)237 messenger1.set_host(comp1)238 messenger2.set_host(comp2)239 comp1_timer = Timer()240 comp2_timer = Timer()241 comp1.get_service(comp1_timer)242 comp2.get_service(comp2_timer)243 comp1_timer.set_host(comp1)244 comp2_timer.set_host(comp2)245246 net = Network()247 net.add_host(ntp_serv, "10.20.30.40")248 net.add_host(msg_server, "1.1.1.1")249 net.add_host(msg_server_rep1, "1.1.2.1")250 net.add_host(msg_server_rep2, "1.1.2.2")251 net.add_host(comp1, "172.10.1.1")252 net.add_host(comp2, "172.10.1.2")253254 net.set_ntp("10.20.30.40")255 msg_server_daemon.add_replic(msg_server_rep1_daemon)256 msg_server_daemon.add_replic(msg_server_rep2_daemon)257258 comp1.services["Messenger"].send_msg("172.10.1.2", "Hello")259 comp1.services["Messenger"].download_history()260 result = comp1.services["Messenger"].history.get_messages_num()261 self.assertEqual(result, 1)262263 def test_send_msg_and_download_history_without_replic(self):264 ntp_serv_daemon = NTPServer()265 ntp_serv = Computer()266 ntp_serv.get_service(ntp_serv_daemon)267 ntp_serv_daemon.set_host(ntp_serv)268269 msg_server_daemon = MSGServer()270 msg_server = Computer()271 msg_server.get_service(msg_server_daemon)272 msg_server_daemon.set_host(msg_server)273 msg_server_timer = Timer()274 msg_server.get_service(msg_server_timer)275 msg_server_timer.set_host(msg_server)276277 messenger1 = Messenger()278 messenger2 = Messenger()279 messenger1.set_msg_server("1.1.1.1")280 messenger2.set_msg_server("1.1.1.1")281 comp1 = Computer()282 comp2 = Computer()283 comp1.get_service(messenger1)284 comp2.get_service(messenger2)285 messenger1.set_host(comp1)286 messenger2.set_host(comp2)287 comp1_timer = Timer()288 comp2_timer = Timer()289 comp1.get_service(comp1_timer)290 comp2.get_service(comp2_timer)291 comp1_timer.set_host(comp1)292 comp2_timer.set_host(comp2)293294 net = Network()295 net.add_host(ntp_serv, "10.20.30.40")296 net.add_host(msg_server, "1.1.1.1")297 net.add_host(comp1, "172.10.1.1")298 net.add_host(comp2, "172.10.1.2")299300 net.set_ntp("10.20.30.40")301302 comp1.services["Messenger"].send_msg("172.10.1.2", "Hello")303 comp1.services["Messenger"].download_history()304 result = comp1.services["Messenger"].history.get_messages_num()305 self.assertEqual(result, 1)306307 def test_send_msg_and_download_history_broken_replic(self):308 ntp_serv_daemon = NTPServer()309 ntp_serv = Computer()310 ntp_serv.get_service(ntp_serv_daemon)311 ntp_serv_daemon.set_host(ntp_serv)312313 msg_server_daemon = MSGServer()314 msg_server = Computer()315 msg_server.get_service(msg_server_daemon)316 msg_server_daemon.set_host(msg_server)317 msg_server_timer = Timer()318 msg_server.get_service(msg_server_timer)319 msg_server_timer.set_host(msg_server)320321 msg_server_rep1_daemon = MSGServerReplic()322 msg_server_rep1 = Computer()323 msg_server_rep1.get_service(msg_server_rep1_daemon)324 msg_server_rep1_daemon.set_host(msg_server_rep1)325 msg_server_rep1_timer = Timer()326 msg_server_rep1.get_service(msg_server_rep1_timer)327 msg_server_rep1_timer.set_host(msg_server_rep1)328329 msg_server_rep2_daemon = MSGServerReplic()330 msg_server_rep2 = Computer()331 msg_server_rep2.get_service(msg_server_rep2_daemon)332 msg_server_rep2_daemon.set_host(msg_server_rep2)333 msg_server_rep2_timer = Timer()334 msg_server_rep2.get_service(msg_server_rep2_timer)335 msg_server_rep2_timer.set_host(msg_server_rep2)336337 messenger1 = Messenger()338 messenger2 = Messenger()339 messenger1.set_msg_server("1.1.1.1")340 messenger2.set_msg_server("1.1.1.1")341 comp1 = Computer()342 comp2 = Computer()343 comp1.get_service(messenger1)344 comp2.get_service(messenger2)345 messenger1.set_host(comp1)346 messenger2.set_host(comp2)347 comp1_timer = Timer()348 comp2_timer = Timer()349 comp1.get_service(comp1_timer)350 comp2.get_service(comp2_timer)351 comp1_timer.set_host(comp1)352 comp2_timer.set_host(comp2)353354 net = Network()355 net.add_host(ntp_serv, "10.20.30.40")356 net.add_host(msg_server, "1.1.1.1")357 net.add_host(msg_server_rep1, "1.1.2.1")358 net.add_host(msg_server_rep2, "1.1.2.2")359 net.add_host(comp1, "172.10.1.1")360 net.add_host(comp2, "172.10.1.2")361362 net.set_ntp("10.20.30.40")363 msg_server_daemon.add_replic(msg_server_rep1_daemon)364 msg_server_daemon.add_replic(msg_server_rep2_daemon)365366 comp1.services["Messenger"].send_msg("172.10.1.2", "Hello") ...

Full Screen

Full Screen

test_dns.py

Source:test_dns.py Github

copy

Full Screen

1import unittest2from general import genral 3from dns import dns 4class TestDns ( unittest . TestCase ):5 "" "Test: records in an empty database" ""6 def test_empty_dns ( self ):7 d1 = DnsRecursive ()8 cd1 = Computer ( "cd1" )9 cd1 . get_service ( d1 )10 d1 . set_host ( cd1 )11 result = d1 . db . num_records ()12 self . assertEqual ( result , 0 )13 "" "Test: Add a record to the database" ""14 def test_add_dns_record ( self ):15 d1 = DnsRecursive ()16 cd1 = Computer ( "cd1" )17 cd1 . get_service ( d1 )18 d1 . set_host ( cd1 )19 d1 . db . form_record ( "ya.ru" , "10.20.30.40" )20 result = d1 . db . num_records ()21 self . assertEqual ( result , 1 )22 "" "Test: deleting a record from the database" ""23 def test_delete_dns_record ( self ):24 d1 = DnsRecursive ()25 cd1 = Computer ( "cd1" )26 cd1 . get_service ( d1 )27 d1 . set_host ( cd1 )28 d1 . db . form_record ( "ya.ru" , "10.20.30.40" )29 result = d1 . db . num_records ()30 self . assertEqual ( result , 1 )31 d1 . db . delete_record ( "ya.ru" )32 result = d1 . db . num_records ()33 self . assertEqual ( result , 0 )34 "" "Test: Resolving name from empty databases recursively" ""35 def test_resolve_blank_dns_recursive ( self ):36 comp1 = Computer ( "First" )37 d1 = DnsRecursive ()38 d2 = DnsRecursive ()39 d1 . set_dns ( "8.8.4.4" )40 cd1 = Computer ( "cd1" )41 cd1 . get_service ( d1 )42 cd2 = Computer ( "cd2" )43 cd2 . get_service ( d2 )44 d1 . set_host ( cd1 )45 d2 . set_host ( cd2 )46 net = Network ()47 net . set_dns ( "8.8.8.8" )48 net . add_host ( comp1 , "172.10.10.1" )49 comp1 . get_interface (). get_dns ()50 net . add_host ( cd1 , "8.8.8.8" )51 net . add_host ( cd2 , "8.8.4.4" )52 result = comp1 . resolve ( "any" )53 self . assertEqual ( result , "Unknown host" )54 "" "Test: Resolving the name from the first database recursively" ""55 def test_resolve_1st_dns_recursive ( self ):56 comp1 = Computer ( "First" )57 d1 = DnsRecursive ()58 d2 = DnsRecursive ()59 d1 . set_dns ( "8.8.4.4" )60 cd1 = Computer ( "cd1" )61 cd1 . get_service ( d1 )62 cd2 = Computer ( "cd2" )63 cd2 . get_service ( d2 )64 d1 . set_host ( cd1 )65 d2 . set_host ( cd2 )66 net = Network ()67 net . set_dns ( "8.8.8.8" )68 net . add_host ( comp1 , "172.10.10.1" )69 comp1 . get_interface (). get_dns ()70 net . add_host ( cd1 , "8.8.8.8" )71 net . add_host ( cd2 , "8.8.4.4" )72 d1 . db . form_record ( "google.com" , "1.2.3.4" )73 result = comp1 . resolve ( "google.com" )74 self . assertEqual ( result , "1.2.3.4" )75 "" "Test: Resolve name from second database recursively" ""76 def test_resolve_2nd_dns_recursive ( self ):77 comp1 = Computer ( "First" )78 d1 = DnsRecursive ()79 d2 = DnsRecursive ()80 d1 . set_dns ( "8.8.4.4" )81 cd1 = Computer ( "cd1" )82 cd1 . get_service ( d1 )83 cd2 = Computer ( "cd2" )84 cd2 . get_service ( d2 )85 d1 . set_host ( cd1 )86 d2 . set_host ( cd2 )87 net = Network ()88 net . set_dns ( "8.8.8.8" )89 net . add_host ( comp1 , "172.10.10.1" )90 comp1 . get_interface (). get_dns ()91 net . add_host ( cd1 , "8.8.8.8" )92 net . add_host ( cd2 , "8.8.4.4" )93 d2 . db . form_record ( "google.com" , "1.2.3.4" )94 result = comp1 . resolve ( "google.com" )95 self . assertEqual ( result , "1.2.3.4" )96 "" "Test: resolving name from empty databases non-recursively" ""97 def test_resolve_blank_dns_nonrecursive ( self ):98 comp1 = Computer ( "First" )99 d1 = DnsNonRecursive ()100 d2 = DnsNonRecursive ()101 d1 . set_dns ( "8.8.4.4" )102 cd1 = Computer ( "cd1" )103 cd1 . get_service ( d1 )104 cd2 = Computer ( "cd2" )105 cd2 . get_service ( d2 )106 d1 . set_host ( cd1 )107 d2 . set_host ( cd2 )108 net = Network ()109 net . set_dns ( "8.8.8.8" )110 net . add_host ( comp1 , "172.10.10.1" )111 comp1 . get_interface (). get_dns ()112 net . add_host ( cd1 , "8.8.8.8" )113 net . add_host ( cd2 , "8.8.4.4" )114 result = comp1 . resolve ( "any" )115 self . assertEqual ( result , "Unknown host" )116 "" "Test: Resolving name from first database non-recursively" ""117 def test_resolve_1st_dns_nonrecursive ( self ):118 comp1 = Computer ( "First" )119 d1 = DnsNonRecursive ()120 d2 = DnsNonRecursive ()121 d1 . set_dns ( "8.8.4.4" )122 cd1 = Computer ( "cd1" )123 cd1 . get_service ( d1 )124 cd2 = Computer ( "cd2" )125 cd2 . get_service ( d2 )126 d1 . set_host ( cd1 )127 d2 . set_host ( cd2 )128 net = Network ()129 net . set_dns ( "8.8.8.8" )130 net . add_host ( comp1 , "172.10.10.1" )131 comp1 . get_interface (). get_dns ()132 net . add_host ( cd1 , "8.8.8.8" )133 net . add_host ( cd2 , "8.8.4.4" )134 d1 . db . form_record ( "google.com" , "1.2.3.4" )135 result = comp1 . resolve ( "google.com" )136 self . assertEqual ( result , "1.2.3.4" )137 "" "Test: Resolving name from second database non-recursively" ""138 def test_resolve_2nd_dns_nonrecursive ( self ):139 comp1 = Computer ( "First" )140 d1 = DnsNonRecursive ()141 d2 = DnsNonRecursive ()142 d1 . set_dns ( "8.8.4.4" )143 cd1 = Computer ( "cd1" )144 cd1 . get_service ( d1 )145 cd2 = Computer ( "cd2" )146 cd2 . get_service ( d2 )147 d1 . set_host ( cd1 )148 d2 . set_host ( cd2 )149 net = Network ()150 net . set_dns ( "8.8.8.8" )151 net . add_host ( comp1 , "172.10.10.1" )152 comp1 . get_interface (). get_dns ()153 net . add_host ( cd1 , "8.8.8.8" )154 net . add_host ( cd2 , "8.8.4.4" )155 d2 . db . form_record ( "google.com" , "1.2.3.4" )156 result = comp1 . resolve ( "google.com" )157 self . assertEqual ( result , "1.2.3.4" )158if __name__ == '__main__' :...

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