Best Python code snippet using tempest_python
test_disk_config.py
Source:test_disk_config.py
1begin_unit2comment|'# Copyright 2012 Nebula, Inc.'3nl|'\n'4comment|'# Copyright 2013 IBM Corp.'5nl|'\n'6comment|'#'7nl|'\n'8comment|'# Licensed under the Apache License, Version 2.0 (the "License"); you may'9nl|'\n'10comment|'# not use this file except in compliance with the License. You may obtain'11nl|'\n'12comment|'# a copy of the License at'13nl|'\n'14comment|'#'15nl|'\n'16comment|'# http://www.apache.org/licenses/LICENSE-2.0'17nl|'\n'18comment|'#'19nl|'\n'20comment|'# Unless required by applicable law or agreed to in writing, software'21nl|'\n'22comment|'# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT'23nl|'\n'24comment|'# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the'25nl|'\n'26comment|'# License for the specific language governing permissions and limitations'27nl|'\n'28comment|'# under the License.'29nl|'\n'30nl|'\n'31name|'from'32name|'oslo_config'33name|'import'34name|'cfg'35newline|'\n'36nl|'\n'37name|'from'38name|'nova'39op|'.'40name|'tests'41op|'.'42name|'functional'43op|'.'44name|'api_sample_tests'45name|'import'46name|'test_servers'47newline|'\n'48name|'from'49name|'nova'50op|'.'51name|'tests'52op|'.'53name|'unit'54op|'.'55name|'image'56name|'import'57name|'fake'58newline|'\n'59nl|'\n'60DECL|variable|CONF61name|'CONF'62op|'='63name|'cfg'64op|'.'65name|'CONF'66newline|'\n'67name|'CONF'68op|'.'69name|'import_opt'70op|'('71string|"'osapi_compute_extension'"72op|','73nl|'\n'74string|"'nova.api.openstack.compute.legacy_v2.extensions'"75op|')'76newline|'\n'77nl|'\n'78nl|'\n'79DECL|class|DiskConfigJsonTest80name|'class'81name|'DiskConfigJsonTest'82op|'('83name|'test_servers'84op|'.'85name|'ServersSampleBase'86op|')'87op|':'88newline|'\n'89DECL|variable|extension_name90indent|' '91name|'extension_name'92op|'='93string|"'os-disk-config'"94newline|'\n'95DECL|variable|extra_extensions_to_load96name|'extra_extensions_to_load'97op|'='98op|'['99string|'"os-access-ips"'100op|']'101newline|'\n'102nl|'\n'103DECL|member|_get_flags104name|'def'105name|'_get_flags'106op|'('107name|'self'108op|')'109op|':'110newline|'\n'111indent|' '112name|'f'113op|'='114name|'super'115op|'('116name|'DiskConfigJsonTest'117op|','118name|'self'119op|')'120op|'.'121name|'_get_flags'122op|'('123op|')'124newline|'\n'125name|'f'126op|'['127string|"'osapi_compute_extension'"128op|']'129op|'='130name|'CONF'131op|'.'132name|'osapi_compute_extension'133op|'['134op|':'135op|']'136newline|'\n'137name|'f'138op|'['139string|"'osapi_compute_extension'"140op|']'141op|'.'142name|'append'143op|'('144nl|'\n'145string|"'nova.api.openstack.compute.contrib.keypairs.Keypairs'"146op|')'147newline|'\n'148name|'f'149op|'['150string|"'osapi_compute_extension'"151op|']'152op|'.'153name|'append'154op|'('155nl|'\n'156string|"'nova.api.openstack.compute.contrib.extended_ips.Extended_ips'"157op|')'158newline|'\n'159name|'f'160op|'['161string|"'osapi_compute_extension'"162op|']'163op|'.'164name|'append'165op|'('166nl|'\n'167string|"'nova.api.openstack.compute.contrib.extended_ips_mac.'"168nl|'\n'169string|"'Extended_ips_mac'"170op|')'171newline|'\n'172name|'f'173op|'['174string|"'osapi_compute_extension'"175op|']'176op|'.'177name|'append'178op|'('179nl|'\n'180string|"'nova.api.openstack.compute.contrib.disk_config.'"181nl|'\n'182string|"'Disk_config'"183op|')'184newline|'\n'185name|'return'186name|'f'187newline|'\n'188nl|'\n'189DECL|member|test_list_servers_detail190dedent|''191name|'def'192name|'test_list_servers_detail'193op|'('194name|'self'195op|')'196op|':'197newline|'\n'198indent|' '199name|'uuid'200op|'='201name|'self'202op|'.'203name|'_post_server'204op|'('205name|'use_common_server_api_samples'206op|'='207name|'False'208op|')'209newline|'\n'210name|'response'211op|'='212name|'self'213op|'.'214name|'_do_get'215op|'('216string|"'servers/detail'"217op|')'218newline|'\n'219name|'subs'220op|'='221op|'{'222op|'}'223newline|'\n'224name|'subs'225op|'['226string|"'hostid'"227op|']'228op|'='229string|"'[a-f0-9]+'"230newline|'\n'231name|'subs'232op|'['233string|"'access_ip_v4'"234op|']'235op|'='236string|"''"237newline|'\n'238name|'subs'239op|'['240string|"'access_ip_v6'"241op|']'242op|'='243string|"''"244newline|'\n'245name|'subs'246op|'['247string|"'id'"248op|']'249op|'='250name|'uuid'251newline|'\n'252name|'self'253op|'.'254name|'_verify_response'255op|'('256string|"'list-servers-detail-get'"257op|','258name|'subs'259op|','260name|'response'261op|','262number|'200'263op|')'264newline|'\n'265nl|'\n'266DECL|member|test_get_server267dedent|''268name|'def'269name|'test_get_server'270op|'('271name|'self'272op|')'273op|':'274newline|'\n'275indent|' '276name|'uuid'277op|'='278name|'self'279op|'.'280name|'_post_server'281op|'('282name|'use_common_server_api_samples'283op|'='284name|'False'285op|')'286newline|'\n'287name|'response'288op|'='289name|'self'290op|'.'291name|'_do_get'292op|'('293string|"'servers/%s'"294op|'%'295name|'uuid'296op|')'297newline|'\n'298name|'subs'299op|'='300op|'{'301op|'}'302newline|'\n'303name|'subs'304op|'['305string|"'hostid'"306op|']'307op|'='308string|"'[a-f0-9]+'"309newline|'\n'310name|'subs'311op|'['312string|"'access_ip_v4'"313op|']'314op|'='315string|"''"316newline|'\n'317name|'subs'318op|'['319string|"'access_ip_v6'"320op|']'321op|'='322string|"''"323newline|'\n'324name|'self'325op|'.'326name|'_verify_response'327op|'('328string|"'server-get-resp'"329op|','330name|'subs'331op|','332name|'response'333op|','334number|'200'335op|')'336newline|'\n'337nl|'\n'338DECL|member|test_resize_server339dedent|''340name|'def'341name|'test_resize_server'342op|'('343name|'self'344op|')'345op|':'346newline|'\n'347indent|' '348name|'self'349op|'.'350name|'flags'351op|'('352name|'allow_resize_to_same_host'353op|'='354name|'True'355op|')'356newline|'\n'357name|'uuid'358op|'='359name|'self'360op|'.'361name|'_post_server'362op|'('363name|'use_common_server_api_samples'364op|'='365name|'False'366op|')'367newline|'\n'368name|'response'369op|'='370name|'self'371op|'.'372name|'_do_post'373op|'('374string|"'servers/%s/action'"375op|'%'376name|'uuid'377op|','378nl|'\n'379string|"'server-resize-post-req'"380op|','381op|'{'382op|'}'383op|')'384newline|'\n'385name|'self'386op|'.'387name|'assertEqual'388op|'('389number|'202'390op|','391name|'response'392op|'.'393name|'status_code'394op|')'395newline|'\n'396comment|'# NOTE(tmello): Resize does not return response body'397nl|'\n'398comment|'# Bug #1085213.'399nl|'\n'400name|'self'401op|'.'402name|'assertEqual'403op|'('404string|'""'405op|','406name|'response'407op|'.'408name|'content'409op|')'410newline|'\n'411nl|'\n'412DECL|member|test_rebuild_server413dedent|''414name|'def'415name|'test_rebuild_server'416op|'('417name|'self'418op|')'419op|':'420newline|'\n'421indent|' '422name|'uuid'423op|'='424name|'self'425op|'.'426name|'_post_server'427op|'('428name|'use_common_server_api_samples'429op|'='430name|'False'431op|')'432newline|'\n'433name|'subs'434op|'='435op|'{'436nl|'\n'437string|"'image_id'"438op|':'439name|'fake'440op|'.'441name|'get_valid_image_id'442op|'('443op|')'444op|','445nl|'\n'446string|"'compute_endpoint'"447op|':'448name|'self'449op|'.'450name|'_get_compute_endpoint'451op|'('452op|')'453op|','454nl|'\n'455op|'}'456newline|'\n'457name|'response'458op|'='459name|'self'460op|'.'461name|'_do_post'462op|'('463string|"'servers/%s/action'"464op|'%'465name|'uuid'466op|','467nl|'\n'468string|"'server-action-rebuild-req'"469op|','470name|'subs'471op|')'472newline|'\n'473name|'subs'474op|'['475string|"'hostid'"476op|']'477op|'='478string|"'[a-f0-9]+'"479newline|'\n'480name|'subs'481op|'['482string|"'access_ip_v4'"483op|']'484op|'='485string|"''"486newline|'\n'487name|'subs'488op|'['489string|"'access_ip_v6'"490op|']'491op|'='492string|"''"493newline|'\n'494name|'self'495op|'.'496name|'_verify_response'497op|'('498string|"'server-action-rebuild-resp'"499op|','500nl|'\n'501name|'subs'502op|','503name|'response'504op|','505number|'202'506op|')'507newline|'\n'508dedent|''509dedent|''510endmarker|''...
test_servers.py
Source:test_servers.py
...104 cs.assert_called('POST', '/servers/1234/action')105 cs.servers.rebuild(s, image=1)106 cs.assert_called('POST', '/servers/1234/action')107 108def test_resize_server():109 s = cs.servers.get(1234)110 s.resize(flavor=1)111 cs.assert_called('POST', '/servers/1234/action')112 cs.servers.resize(s, flavor=1)113 cs.assert_called('POST', '/servers/1234/action')114 115def test_confirm_resized_server():116 s = cs.servers.get(1234)117 s.confirm_resize()118 cs.assert_called('POST', '/servers/1234/action')119 cs.servers.confirm_resize(s)120 cs.assert_called('POST', '/servers/1234/action')121 122def test_revert_resized_server():...
test_resize_server_burn_in.py
Source:test_resize_server_burn_in.py
...31 resp = cls.server_behaviors.create_active_server()32 cls.server = resp.entity33 cls.resources.add(cls.server.id, cls.servers_client.delete_server)34 @tags(type='burn-in', net='no')35 def test_resize_server(self):36 self.server_behaviors.resize_and_await(37 self.server.id, self.flavor_ref_alt)38 @tags(type='burn-in', net='no')39 def test_resize_server_confirm(self):40 self.servers_client.confirm_resize(self.server.id)...
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!!