How to use test_delete_pass method in tempest

Best Python code snippet using tempest_python

test_cleanup_services.py

Source:test_cleanup_services.py Github

copy

Full Screen

...267 delete_mock = [(self.get_method, self.response, 200),268 (self.delete_method, 'error', None),269 (self.log_method, 'exception', None)]270 self._test_delete(delete_mock, fail=True)271 def test_delete_pass(self):272 delete_mock = [(self.get_method, self.response, 200),273 (self.delete_method, None, 202),274 (self.log_method, 'exception', None)]275 self._test_delete(delete_mock)276 def test_dry_run(self):277 dry_mock = [(self.get_method, self.response, 200),278 (self.delete_method, "delete", None)]279 self._test_dry_run_true(dry_mock)280 def test_save_state(self):281 self._test_saved_state_true([(self.get_method, self.response, 200)])282class TestServerService(BaseCmdServiceTests):283 service_class = 'ServerService'284 service_name = 'servers'285 response = {286 "servers": [287 {288 "id": "22c91117-08de-4894-9aa9-6ef382400985",289 "links": [290 {291 "href": "http://openstack.example.com/v2/6f70-6ef0985",292 "rel": "self"293 },294 {295 "href": "http://openstack.example.com/6f70656e7-6ef35",296 "rel": "bookmark"297 }298 ],299 "name": "new-server-test"300 },301 {302 "id": "7a6d4v7w-36ds-4216",303 "links": [304 {305 "href": "http://openstack.example.com/v2/6f70-6ef0985",306 "rel": "self"307 },308 {309 "href": "http://openstack.example.com/6f70656e7-6ef35",310 "rel": "bookmark"311 }312 ],313 "name": "saved-server"314 }315 ]316 }317 def test_delete_fail(self):318 delete_mock = [(self.get_method, self.response, 200),319 (self.delete_method, 'error', None),320 (self.log_method, 'exception', None)]321 self._test_delete(delete_mock, fail=True)322 def test_delete_pass(self):323 delete_mock = [(self.get_method, self.response, 200),324 (self.delete_method, None, 204),325 (self.log_method, 'exception', None)]326 self._test_delete(delete_mock)327 def test_dry_run(self):328 dry_mock = [(self.get_method, self.response, 200),329 (self.delete_method, "delete", None)]330 self._test_dry_run_true(dry_mock)331 def test_save_state(self):332 self._test_saved_state_true([(self.get_method, self.response, 200)])333class TestServerGroupService(BaseCmdServiceTests):334 service_class = 'ServerGroupService'335 service_name = 'server_groups'336 validate_response = ('tempest.lib.services.compute.server_groups_client'337 '.ServerGroupsClient.validate_response')338 response = {339 "server_groups": [340 {341 "id": "616fb98f-46ca-475e-917e-2563e5a8cd19",342 "name": "test",343 "policy": "anti-affinity",344 "rules": {"max_server_per_host": 3},345 "members": [],346 "project_id": "6f70656e737461636b20342065766572",347 "user_id": "fake"348 },349 {350 "id": "as6d5f7g-46ca-475e",351 "name": "saved-server-group"352 }353 ]354 }355 def test_delete_fail(self):356 delete_mock = [(self.get_method, self.response, 200),357 (self.validate_response, 'validate', None),358 (self.delete_method, 'error', None),359 (self.log_method, 'exception', None)]360 self._test_delete(delete_mock, fail=True)361 def test_delete_pass(self):362 delete_mock = [(self.get_method, self.response, 200),363 (self.validate_response, 'validate', None),364 (self.delete_method, None, 204),365 (self.log_method, 'exception', None)]366 self._test_delete(delete_mock)367 def test_dry_run(self):368 dry_mock = [(self.get_method, self.response, 200),369 (self.validate_response, 'validate', None),370 (self.delete_method, "delete", None)]371 self._test_dry_run_true(dry_mock)372 def test_save_state(self):373 self._test_saved_state_true([(self.get_method, self.response, 200),374 (self.validate_response, 'validate', None)375 ])376class TestKeyPairService(BaseCmdServiceTests):377 service_class = 'KeyPairService'378 service_name = 'keypairs'379 validate_response = ('tempest.lib.services.compute.keypairs_client'380 '.KeyPairsClient.validate_response')381 response = {382 "keypairs": [383 {384 "keypair": {385 "fingerprint": "7e:eb:ab:24:ba:d1:e1:88:ae:9a:fb:66:53:bd",386 "name": "keypair-5d935425-31d5-48a7-a0f1-e76e9813f2c3",387 "type": "ssh",388 "public_key": "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCkF\n"389 }390 },391 {392 "keypair": {393 "fingerprint": "7e:eb:ab:24",394 "name": "saved-key-pair"395 }396 }397 ]398 }399 def _test_saved_state_true(self, mocked_fixture_tuple_list):400 serv = self._create_cmd_service(self.service_class, is_save_state=True)401 _, fixtures = self.run_function_with_mocks(402 serv.run,403 mocked_fixture_tuple_list404 )405 for item in self.response[self.service_name]:406 self.assertTrue(item['keypair']['name'],407 serv.data[self.service_name])408 for fixture in fixtures:409 fixture.mock.assert_called_once()410 def test_delete_fail(self):411 delete_mock = [(self.get_method, self.response, 200),412 (self.validate_response, 'validate', None),413 (self.delete_method, 'error', None),414 (self.log_method, 'exception', None)]415 self._test_delete(delete_mock, fail=True)416 def test_delete_pass(self):417 delete_mock = [(self.get_method, self.response, 200),418 (self.validate_response, 'validate', None),419 (self.delete_method, None, 204),420 (self.log_method, 'exception', None)]421 self._test_delete(delete_mock)422 def test_dry_run(self):423 dry_mock = [(self.get_method, self.response, 200),424 (self.validate_response, 'validate', None),425 (self.delete_method, "delete", None)]426 self._test_dry_run_true(dry_mock)427 def test_save_state(self):428 self._test_saved_state_true([429 (self.get_method, self.response, 200),430 (self.validate_response, 'validate', None)431 ])432class TestVolumeService(BaseCmdServiceTests):433 service_class = 'VolumeService'434 service_name = 'volumes'435 response = {436 "volumes": [437 {438 "id": "efa54464-8fab-47cd-a05a-be3e6b396188",439 "links": [440 {441 "href": "http://127.0.0.1:37097/v3/89af/volumes/efa54",442 "rel": "self"443 },444 {445 "href": "http://127.0.0.1:37097/89af/volumes/efa54464",446 "rel": "bookmark"447 }448 ],449 "name": "volume-name"450 },451 {452 "id": "aa77asdf-1234",453 "name": "saved-volume"454 }455 ]456 }457 def test_delete_fail(self):458 delete_mock = [(self.get_method, self.response, 200),459 (self.delete_method, 'error', None),460 (self.log_method, 'exception', None)]461 self._test_delete(delete_mock, fail=True)462 def test_delete_pass(self):463 delete_mock = [(self.get_method, self.response, 200),464 (self.delete_method, None, 202),465 (self.log_method, 'exception', None)]466 self._test_delete(delete_mock)467 def test_dry_run(self):468 dry_mock = [(self.get_method, self.response, 200),469 (self.delete_method, "delete", None)]470 self._test_dry_run_true(dry_mock)471 def test_save_state(self):472 self._test_saved_state_true([(self.get_method, self.response, 200)])473# Begin network service classes474class TestNetworkService(BaseCmdServiceTests):475 service_class = 'NetworkService'476 service_name = 'networks'477 response = {478 "networks": [479 {480 "admin_state_up": True,481 "availability_zone_hints": [],482 "availability_zones": [483 "nova"484 ],485 "created_at": "2016-03-08T20:19:41",486 "dns_domain": "my-domain.org.",487 "id": "d32019d3-bc6e-4319-9c1d-6722fc136a22",488 "l2_adjacency": False,489 "mtu": 1500,490 "name": "net1",491 "port_security_enabled": True,492 "project_id": "4fd44f30292945e481c7b8a0c8908869",493 "qos_policy_id": "6a8454ade84346f59e8d40665f878b2e",494 "revision_number": 1,495 "router:external": False,496 "shared": False,497 "status": "ACTIVE",498 "subnets": [499 "54d6f61d-db07-451c-9ab3-b9609b6b6f0b"500 ],501 "tenant_id": "4fd44f30292945e481c7b8a0c8908869",502 "updated_at": "2016-03-08T20:19:41",503 "vlan_transparent": True,504 "description": "",505 "is_default": False506 },507 {508 "id": "6722fc13-4319",509 "name": "saved-network"510 }511 ]512 }513 def test_delete_fail(self):514 delete_mock = [(self.get_method, self.response, 200),515 (self.delete_method, 'error', None),516 (self.log_method, 'exception', None)]517 self._test_delete(delete_mock, fail=True)518 def test_delete_pass(self):519 delete_mock = [(self.get_method, self.response, 200),520 (self.delete_method, None, 204),521 (self.log_method, 'exception', None)]522 self._test_delete(delete_mock)523 def test_dry_run(self):524 dry_mock = [(self.get_method, self.response, 200),525 (self.delete_method, "delete", None)]526 self._test_dry_run_true(dry_mock)527 def test_save_state(self):528 self._test_saved_state_true([(self.get_method, self.response, 200)])529 def test_preserve_list(self):530 self.response['networks'].append(531 {532 "admin_state_up": True,533 "availability_zone_hints": [],534 "availability_zones": [535 "nova"536 ],537 "created_at": "2017-03-08T20:19:41",538 "dns_domain": "my-domain.org.",539 "id": cleanup_service.CONF_PUB_NETWORK,540 "name": "net2",541 "port_security_enabled": True,542 "project_id": "4fd44f30292945e481c7b8a0c8908869",543 "qos_policy_id": "6a8454ade84346f59e8d40665f878b2e",544 "revision_number": 1,545 "status": "ACTIVE",546 "subnets": [547 "54d6f61d-db07-451c-9ab3-b9609b6b6f0b"548 ],549 "tenant_id": "4fd44f30292945e481c7b8a0c8908869",550 "updated_at": "2018-03-08T20:19:41",551 "vlan_transparent": True,552 "is_default": False553 })554 self._test_is_preserve_true([(self.get_method, self.response, 200)])555class TestNetworkFloatingIpService(BaseCmdServiceTests):556 service_class = 'NetworkFloatingIpService'557 service_name = 'floatingips'558 response = {559 "floatingips": [560 {561 "router_id": "d23abc8d-2991-4a55-ba98-2aaea84cc72f",562 "description": "for test",563 "dns_domain": "my-domain.org.",564 "dns_name": "myfip",565 "created_at": "2016-12-21T10:55:50Z",566 "updated_at": "2016-12-21T10:55:53Z",567 "revision_number": 1,568 "project_id": "4969c491a3c74ee4af974e6d800c62de",569 "tenant_id": "4969c491a3c74ee4af974e6d800c62de",570 "floating_network_id": "376da547-b977-4cfe-9cba-275c80debf57",571 "fixed_ip_address": "10.0.0.3",572 "floating_ip_address": "172.24.4.228",573 "port_id": "ce705c24-c1ef-408a-bda3-7bbd946164ab",574 "id": "2f245a7b-796b-4f26-9cf9-9e82d248fda7",575 "status": "ACTIVE",576 "port_details": {577 "status": "ACTIVE",578 "name": "",579 "admin_state_up": True,580 "network_id": "02dd8479-ef26-4398-a102-d19d0a7b3a1f",581 "device_owner": "compute:nova",582 "mac_address": "fa:16:3e:b1:3b:30",583 "device_id": "8e3941b4-a6e9-499f-a1ac-2a4662025cba"584 },585 "tags": ["tag1,tag2"],586 "port_forwardings": []587 },588 {589 "id": "9e82d248-408a",590 "status": "ACTIVE"591 }592 ]593 }594 def test_delete_fail(self):595 delete_mock = [(self.get_method, self.response, 200),596 (self.delete_method, 'error', None),597 (self.log_method, 'exception', None)]598 self._test_delete(delete_mock, fail=True)599 def test_delete_pass(self):600 delete_mock = [(self.get_method, self.response, 200),601 (self.delete_method, None, 204),602 (self.log_method, 'exception', None)]603 self._test_delete(delete_mock)604 def test_dry_run(self):605 dry_mock = [(self.get_method, self.response, 200),606 (self.delete_method, "delete", None)]607 self._test_dry_run_true(dry_mock)608 def test_save_state(self):609 self._test_saved_state_true([(self.get_method, self.response, 200)])610class TestNetworkRouterService(BaseCmdServiceTests):611 service_class = 'NetworkRouterService'612 service_name = 'routers'613 validate_response = ('tempest.lib.services.network.routers_client'614 '.RoutersClient.validate_response')615 response = {616 "routers": [617 {618 "admin_state_up": True,619 "availability_zone_hints": [],620 "availability_zones": [621 "nova"622 ],623 "created_at": "2018-03-19T19:17:04Z",624 "description": "",625 "distributed": False,626 "external_gateway_info": {627 "enable_snat": True,628 "external_fixed_ips": [629 {630 "ip_address": "172.24.4.3",631 "subnet_id": "b930d7f6-ceb7-40a0-8b81-a425dd994ccf"632 },633 {634 "ip_address": "2001:db8::c",635 "subnet_id": "0c56df5d-ace5-46c8-8f4c-45fa4e334d18"636 }637 ],638 "network_id": "ae34051f-aa6c-4c75-abf5-50dc9ac99ef3"639 },640 "flavor_id": "f7b14d9a-b0dc-4fbe-bb14-a0f4970a69e0",641 "ha": False,642 "id": "915a14a6-867b-4af7-83d1-70efceb146f9",643 "name": "router2",644 "revision_number": 1,645 "routes": [646 {647 "destination": "179.24.1.0/24",648 "nexthop": "172.24.3.99"649 }650 ],651 "status": "ACTIVE",652 "updated_at": "2018-03-19T19:17:22Z",653 "project_id": "0bd18306d801447bb457a46252d82d13",654 "tenant_id": "0bd18306d801447bb457a46252d82d13",655 "tags": ["tag1,tag2"]656 },657 {658 "id": "4s5w34hj-id44",659 "name": "saved-router"660 }661 ],662 # "ports" key is added to the response in order to simplify unit663 # testing - it's because NetworkRouterService's delete method lists664 # ports before deleting any router665 "ports": []666 }667 def _test_delete(self, mocked_fixture_tuple_list, fail=False):668 serv = self._create_cmd_service(self.service_class)669 resp, fixtures = self.run_function_with_mocks(670 serv.run,671 mocked_fixture_tuple_list,672 )673 for fixture in fixtures:674 if fail is False and fixture.mock.return_value == 'exception':675 fixture.mock.assert_not_called()676 elif self.service_name in self.saved_state.keys():677 fixture.mock.assert_called()678 for key in self.saved_state[self.service_name].keys():679 self.assertNotIn(key, fixture.mock.call_args[0][0])680 self.assertFalse(serv.data)681 def test_delete_fail(self):682 delete_mock = [(self.get_method, self.response, 200),683 (self.delete_method, 'error', None),684 (self.log_method, 'exception', None)]685 self._test_delete(delete_mock, fail=True)686 def test_delete_pass(self):687 delete_mock = [(self.get_method, self.response, 200),688 (self.delete_method, None, 204),689 (self.log_method, 'exception', None)]690 self._test_delete(delete_mock)691 def test_dry_run(self):692 dry_mock = [(self.get_method, self.response, 200),693 (self.delete_method, "delete", None)]694 self._test_dry_run_true(dry_mock)695 def test_save_state(self):696 self._test_saved_state_true([(self.get_method, self.response, 200)])697 def test_preserve_list(self):698 self.response['routers'].append(699 {700 "admin_state_up": True,701 "availability_zone_hints": [],702 "availability_zones": [703 "nova"704 ],705 "created_at": "2018-03-19T19:17:04Z",706 "id": cleanup_service.CONF_PUB_ROUTER,707 "name": "router-preserve",708 "status": "ACTIVE",709 "updated_at": "2018-03-19T19:17:22Z",710 "project_id": "0bd18306d801447bb457a46252d82d13",711 "tenant_id": "0bd18306d801447bb457a46252d82d13",712 "tags": ["tag1,tag2"]713 })714 self._test_is_preserve_true([(self.get_method, self.response, 200)])715class TestNetworkMeteringLabelRuleService(BaseCmdServiceTests):716 service_class = 'NetworkMeteringLabelRuleService'717 service_name = 'metering_label_rules'718 response = {719 "metering_label_rules": [720 {721 "remote_ip_prefix": "20.0.0.0/24",722 "direction": "ingress",723 "metering_label_id": "e131d186-b02d-4c0b-83d5-0c0725c4f812",724 "id": "9536641a-7d14-4dc5-afaf-93a973ce0eb8",725 "excluded": False726 },727 {728 "direction": "ingress",729 "id": "93a973ce-4dc5"730 }731 ]732 }733 def test_delete_fail(self):734 delete_mock = [(self.get_method, self.response, 200),735 (self.delete_method, 'error', None),736 (self.log_method, 'exception', None)]737 self._test_delete(delete_mock, fail=True)738 def test_delete_pass(self):739 delete_mock = [(self.get_method, self.response, 200),740 (self.delete_method, None, 204),741 (self.log_method, 'exception', None)]742 self._test_delete(delete_mock)743 def test_dry_run(self):744 dry_mock = [(self.get_method, self.response, 200),745 (self.delete_method, "delete", None)]746 self._test_dry_run_true(dry_mock)747 def test_save_state(self):748 self._test_saved_state_true([(self.get_method, self.response, 200)])749class TestNetworkMeteringLabelService(BaseCmdServiceTests):750 service_class = 'NetworkMeteringLabelService'751 service_name = 'metering_labels'752 response = {753 "metering_labels": [754 {755 "project_id": "45345b0ee1ea477fac0f541b2cb79cd4",756 "tenant_id": "45345b0ee1ea477fac0f541b2cb79cd4",757 "description": "label1 description",758 "name": "label1",759 "id": "a6700594-5b7a-4105-8bfe-723b346ce866",760 "shared": False761 },762 {763 "name": "saved-label",764 "id": "723b346ce866-4c7q",765 }766 ]767 }768 def test_delete_fail(self):769 delete_mock = [(self.get_method, self.response, 200),770 (self.delete_method, 'error', None),771 (self.log_method, 'exception', None)]772 self._test_delete(delete_mock, fail=True)773 def test_delete_pass(self):774 delete_mock = [(self.get_method, self.response, 200),775 (self.delete_method, None, 204),776 (self.log_method, 'exception', None)]777 self._test_delete(delete_mock)778 def test_dry_run(self):779 dry_mock = [(self.get_method, self.response, 200),780 (self.delete_method, "delete", None)]781 self._test_dry_run_true(dry_mock)782 def test_save_state(self):783 self._test_saved_state_true([(self.get_method, self.response, 200)])784class TestNetworkPortService(BaseCmdServiceTests):785 service_class = 'NetworkPortService'786 service_name = 'ports'787 response = {788 "ports": [789 {790 "admin_state_up": True,791 "allowed_address_pairs": [],792 "created_at": "2016-03-08T20:19:41",793 "description": "",794 "device_id": "9ae135f4-b6e0-4dad-9e91-3c223e385824",795 "device_owner": "",796 "dns_assignment": {797 "hostname": "myport",798 "ip_address": "172.24.4.2",799 "fqdn": "myport.my-domain.org"800 },801 "dns_domain": "my-domain.org.",802 "dns_name": "myport",803 "extra_dhcp_opts": [804 {805 "opt_value": "pxelinux.0",806 "ip_version": 4,807 "opt_name": "bootfile-name"808 }809 ],810 "fixed_ips": [811 {812 "ip_address": "172.24.4.2",813 "subnet_id": "008ba151-0b8c-4a67-98b5-0d2b87666062"814 }815 ],816 "id": "d80b1a3b-4fc1-49f3-952e-1e2ab7081d8b",817 "ip_allocation": "immediate",818 "mac_address": "fa:16:3e:58:42:ed",819 "name": "test_port",820 "network_id": "70c1db1f-b701-45bd-96e0-a313ee3430b3",821 "project_id": "",822 "revision_number": 1,823 "security_groups": [],824 "status": "ACTIVE",825 "tags": ["tag1,tag2"],826 "tenant_id": "",827 "updated_at": "2016-03-08T20:19:41",828 "qos_policy_id": "29d5e02e-d5ab-4929-bee4-4a9fc12e22ae",829 "port_security_enabled": False830 },831 {832 "id": "aa74aa4v-741a",833 "name": "saved-port",834 "device_owner": ""835 }836 ]837 }838 def test_delete_fail(self):839 delete_mock = [(self.get_method, self.response, 200),840 (self.delete_method, 'error', None),841 (self.log_method, 'exception', None)]842 self._test_delete(delete_mock, fail=True)843 def test_delete_pass(self):844 delete_mock = [(self.get_method, self.response, 200),845 (self.delete_method, None, 204),846 (self.log_method, 'exception', None)]847 self._test_delete(delete_mock)848 def test_dry_run(self):849 dry_mock = [(self.get_method, self.response, 200),850 (self.delete_method, "delete", None)]851 self._test_dry_run_true(dry_mock)852 def test_save_state(self):853 self._test_saved_state_true([(self.get_method, self.response, 200)])854 def test_preserve_list(self):855 self.response['ports'].append(856 {857 "created_at": "2018-03-08T20:19:41",858 "description": "",859 "device_id": "9ae135f4-b6e0-4dad-9e91-3c223e385824",860 "device_owner": "compute:router_gateway",861 "id": "d80b1a3b-4fc1-49f3-952e-1fdy1ws542",862 "ip_allocation": "immediate",863 "mac_address": "fa:16:3e:58:42:ed",864 "name": "preserve_port",865 "network_id": cleanup_service.CONF_PUB_NETWORK,866 "project_id": "",867 "security_groups": [],868 "status": "ACTIVE",869 "tags": ["tag1,tag2"],870 "tenant_id": "",871 "updated_at": "2018-03-08T20:19:41",872 })873 self._test_is_preserve_true([(self.get_method, self.response, 200)])874class TestNetworkSecGroupService(BaseCmdServiceTests):875 service_class = 'NetworkSecGroupService'876 service_name = 'security_groups'877 response = {878 "security_groups": [879 {880 "description": "default",881 "id": "85cc3048-abc3-43cc-89b3-377341426ac5",882 "name": "test",883 "security_group_rules": [884 {885 "direction": "egress",886 "ethertype": "IPv6",887 "id": "3c0e45ff-adaf-4124-b083-bf390e5482ff",888 "security_group_id": "85cc3048-abc3-43cc-89b3-3773414",889 "project_id": "e4f50856753b4dc6afee5fa6b9b6c550",890 "revision_number": 1,891 "tags": ["tag1,tag2"],892 "tenant_id": "e4f50856753b4dc6afee5fa6b9b6c550",893 "created_at": "2018-03-19T19:16:56Z",894 "updated_at": "2018-03-19T19:16:56Z",895 "description": ""896 }897 ]898 },899 {900 "id": "7q844add-3697",901 "name": "saved-sec-group"902 }903 ]904 }905 def test_delete_fail(self):906 delete_mock = [(self.get_method, self.response, 200),907 (self.delete_method, 'error', None),908 (self.log_method, 'exception', None)]909 self._test_delete(delete_mock, fail=True)910 def test_delete_pass(self):911 delete_mock = [(self.get_method, self.response, 200),912 (self.delete_method, None, 204),913 (self.log_method, 'exception', None)]914 self._test_delete(delete_mock)915 def test_dry_run(self):916 dry_mock = [(self.get_method, self.response, 200),917 (self.delete_method, "delete", None)]918 self._test_dry_run_true(dry_mock)919 def test_save_state(self):920 self._test_saved_state_true([(self.get_method, self.response, 200)])921 def test_preserve_list(self):922 self.response['security_groups'].append(923 {924 "description": "default",925 "id": "85cc3048-abc3-43cc-89b3-377341426ac5",926 "name": "test",927 "security_group_rules": [928 {929 "direction": "egress",930 "ethertype": "IPv6",931 "id": "3c0e45ff-adaf-4124-b083-bf390e5482ff",932 "security_group_id": "85cc3048-abc3-43cc-89b3-3773414",933 "project_id": cleanup_service.CONF_PROJECTS[0],934 "revision_number": 1,935 "tags": ["tag1,tag2"],936 "tenant_id": "e4f50856753b4dc6afee5fa6b9b6c550",937 "created_at": "2018-03-19T19:16:56Z",938 "updated_at": "2018-03-19T19:16:56Z",939 "description": ""940 }941 ]942 })943 self._test_is_preserve_true([(self.get_method, self.response, 200)])944class TestNetworkSubnetService(BaseCmdServiceTests):945 service_class = 'NetworkSubnetService'946 service_name = 'subnets'947 response = {948 "subnets": [949 {950 "name": "private-subnet",951 "enable_dhcp": True,952 "network_id": "db193ab3-96e3-4cb3-8fc5-05f4296d0324",953 "project_id": "26a7980765d0414dbc1fc1f88cdb7e6e",954 "tenant_id": "26a7980765d0414dbc1fc1f88cdb7e6e",955 "dns_nameservers": [],956 "allocation_pools": [957 {958 "start": "10.0.0.2",959 "end": "10.0.0.254"960 }961 ],962 "host_routes": [],963 "ip_version": 4,964 "gateway_ip": "10.0.0.1",965 "cidr": "10.0.0.0/24",966 "id": "08eae331-0402-425a-923c-34f7cfe39c1b",967 "created_at": "2016-10-10T14:35:34Z",968 "revision_number": 2,969 "service_types": [],970 "tags": ["tag1,tag2"],971 "updated_at": "2016-10-10T14:35:34Z"972 },973 {974 "id": "55ttda4a-2584",975 "name": "saved-subnet"976 }977 ]978 }979 def test_delete_fail(self):980 delete_mock = [(self.get_method, self.response, 200),981 (self.delete_method, 'error', None),982 (self.log_method, 'exception', None)]983 self._test_delete(delete_mock, fail=True)984 def test_delete_pass(self):985 delete_mock = [(self.get_method, self.response, 200),986 (self.delete_method, None, 204),987 (self.log_method, 'exception', None)]988 self._test_delete(delete_mock)989 def test_dry_run(self):990 dry_mock = [(self.get_method, self.response, 200),991 (self.delete_method, "delete", None)]992 self._test_dry_run_true(dry_mock)993 def test_save_state(self):994 self._test_saved_state_true([(self.get_method, self.response, 200)])995 def test_preserve_list(self):996 self.response['subnets'].append(997 {998 "name": "public-subnet",999 "network_id": cleanup_service.CONF_PUB_NETWORK,1000 "project_id": "26a7980765d0414dbc1fc1f88cdb7e6e",1001 "tenant_id": "26a7980765d0414dbc1fc1f88cdb7e6e",1002 "ip_version": 4,1003 "gateway_ip": "10.0.0.1",1004 "cidr": "10.0.0.0/24",1005 "id": "08eae331-0402-425a-923c-34f7cfe39c1b",1006 "created_at": "2018-10-10T14:35:34Z",1007 "service_types": [],1008 "tags": ["tag1,tag2"],1009 "updated_at": "2018-10-10T14:35:34Z"1010 })1011 self._test_is_preserve_true([(self.get_method, self.response, 200)])1012class TestNetworkSubnetPoolsService(BaseCmdServiceTests):1013 service_class = 'NetworkSubnetPoolsService'1014 service_name = 'subnetpools'1015 response = {1016 "subnetpools": [1017 {1018 "min_prefixlen": "64",1019 "default_prefixlen": "64",1020 "id": "03f761e6-eee0-43fc-a921-8acf64c14988",1021 "max_prefixlen": "64",1022 "name": "my-subnet-pool-ipv6",1023 "is_default": False,1024 "project_id": "9fadcee8aa7c40cdb2114fff7d569c08",1025 "tenant_id": "9fadcee8aa7c40cdb2114fff7d569c08",1026 "prefixes": [1027 "2001:db8:0:2::/64",1028 "2001:db8::/63"1029 ],1030 "ip_version": 6,1031 "shared": False,1032 "description": "",1033 "created_at": "2016-03-08T20:19:41",1034 "updated_at": "2016-03-08T20:19:41",1035 "revision_number": 2,1036 "tags": ["tag1,tag2"]1037 },1038 {1039 "id": "8acf64c1-43fc",1040 "name": "saved-subnet-pool"1041 }1042 ]1043 }1044 def test_delete_fail(self):1045 delete_mock = [(self.get_method, self.response, 200),1046 (self.delete_method, 'error', None),1047 (self.log_method, 'exception', None)]1048 self._test_delete(delete_mock, fail=True)1049 def test_delete_pass(self):1050 delete_mock = [(self.get_method, self.response, 200),1051 (self.delete_method, None, 204),1052 (self.log_method, 'exception', None)]1053 self._test_delete(delete_mock)1054 def test_dry_run(self):1055 dry_mock = [(self.get_method, self.response, 200),1056 (self.delete_method, "delete", None)]1057 self._test_dry_run_true(dry_mock)1058 def test_save_state(self):1059 self._test_saved_state_true([(self.get_method, self.response, 200)])1060 def test_preserve_list(self):1061 self.response['subnetpools'].append(1062 {1063 "min_prefixlen": "64",1064 "default_prefixlen": "64",1065 "id": "9acf64c1-43fc",1066 "name": "preserve-pool",1067 "project_id": cleanup_service.CONF_PROJECTS[0],1068 "created_at": "2016-03-08T20:19:41",1069 "updated_at": "2016-03-08T20:19:41"1070 })1071 self._test_is_preserve_true([(self.get_method, self.response, 200)])1072# begin global services1073class TestRegionService(BaseCmdServiceTests):1074 service_class = 'RegionService'1075 service_name = 'regions'1076 response = {1077 "regions": [{1078 "parent_region_id": None,1079 "id": "RegionOne",1080 "links": {1081 "self":1082 "http://10.0.145.61:5000/v3/regions/RegionOne"1083 },1084 "description": ""1085 },1086 {1087 "parent_region_id": None,1088 "id": "RegionTwo",1089 "links": {1090 "self":1091 "http://10.0.145.61:5000/v3/regions/RegionTwo"1092 },1093 "description": ""1094 }],1095 "links": {1096 "self":1097 "http://10.0.145.61:5000/v3/regions",1098 "next": None,1099 "previous": None1100 }1101 }1102 def test_delete_pass(self):1103 delete_mock = [(self.get_method, self.response, 200),1104 (self.delete_method, None, 204),1105 (self.log_method, "exception", None)]1106 self._test_delete(delete_mock)1107 def test_delete_fail(self):1108 delete_mock = [(self.get_method, self.response, 200),1109 (self.delete_method, 'error', None),1110 (self.log_method, "exception", None)]1111 self._test_delete(delete_mock, fail=True)1112 def test_dry_run(self):1113 dry_mock = [(self.get_method, self.response, 200),1114 (self.delete_method, "delete", None)]1115 self._test_dry_run_true(dry_mock)1116 def test_save_state(self):1117 self._test_saved_state_true([(self.get_method, self.response, 200)])1118class TestDomainService(BaseCmdServiceTests):1119 service_class = 'DomainService'1120 service_name = 'domains'1121 response = {1122 "domains": [1123 {1124 "description": "Destroy all humans",1125 "enabled": True,1126 "id": "5a75994a3",1127 "links": {1128 "self": "http://example.com/identity/v3/domains/5a75994a3"1129 },1130 "name": "Sky_net"1131 },1132 {1133 "description": "Owns users and tenants on Identity API",1134 "enabled": False,1135 "id": "default",1136 "links": {1137 "self": "http://example.com/identity/v3/domains/default"1138 },1139 "name": "Default"1140 }1141 ]1142 }1143 mock_update = ("tempest.lib.services.identity.v3."1144 "domains_client.DomainsClient.update_domain")1145 def test_delete_fail(self):1146 delete_mock = [(self.get_method, self.response, 200),1147 (self.delete_method, 'error', None),1148 (self.log_method, 'exception', None),1149 (self.mock_update, 'update', None)]1150 self._test_delete(delete_mock, fail=True)1151 def test_delete_pass(self):1152 delete_mock = [(self.get_method, self.response, 200),1153 (self.delete_method, None, 204),1154 (self.log_method, 'exception', None),1155 (self.mock_update, 'update', None)]1156 self._test_delete(delete_mock)1157 def test_dry_run(self):1158 dry_mock = [(self.get_method, self.response, 200),1159 (self.delete_method, "delete", None)]1160 self._test_dry_run_true(dry_mock)1161 def test_save_state(self):1162 self._test_saved_state_true([(self.get_method, self.response, 200)])1163class TestProjectsService(BaseCmdServiceTests):1164 service_class = 'ProjectService'1165 service_name = 'projects'1166 response = {1167 "projects": [1168 {1169 "is_domain": False,1170 "description": None,1171 "domain_id": "default",1172 "enabled": True,1173 "id": "f38ohgp93jj032",1174 "links": {1175 "self": "http://example.com/identity/v3/projects"1176 "/f38ohgp93jj032"1177 },1178 "name": "manhattan",1179 "parent_id": None1180 },1181 {1182 "is_domain": False,1183 "description": None,1184 "domain_id": "default",1185 "enabled": True,1186 "id": "098f89d3292ri4jf4",1187 "links": {1188 "self": "http://example.com/identity/v3/projects"1189 "/098f89d3292ri4jf4"1190 },1191 "name": "Apollo",1192 "parent_id": None1193 }1194 ]1195 }1196 def test_delete_fail(self):1197 delete_mock = [(self.get_method, self.response, 200),1198 (self.delete_method, 'error', None),1199 (self.log_method, 'exception', None)]1200 self._test_delete(delete_mock, fail=True)1201 def test_delete_pass(self):1202 delete_mock = [(self.get_method, self.response, 200),1203 (self.delete_method, None, 204),1204 (self.log_method, 'exception', None)]1205 self._test_delete(delete_mock)1206 def test_dry_run(self):1207 dry_mock = [(self.get_method, self.response, 200),1208 (self.delete_method, "delete", None)]1209 self._test_dry_run_true(dry_mock)1210 def test_save_state(self):1211 self._test_saved_state_true([(self.get_method, self.response, 200)])1212 def test_preserve_list(self):1213 self.response['projects'].append(1214 {1215 "is_domain": False,1216 "description": None,1217 "domain_id": "default",1218 "enabled": True,1219 "id": "r343q98h09f3092",1220 "links": {1221 "self": "http://example.com/identity/v3/projects"1222 "/r343q98h09f3092"1223 },1224 "name": cleanup_service.CONF_PROJECTS[0],1225 "parent_id": None1226 })1227 self._test_is_preserve_true([(self.get_method, self.response, 200)])1228class TestImagesService(BaseCmdServiceTests):1229 service_class = 'ImageService'1230 service_name = 'images'1231 response = {1232 "images": [1233 {1234 "status": "ACTIVE",1235 "name": "stratus-0.3.2-x86_64-disk",1236 "id": "34yhwr-4t3q",1237 "updated": "2014-11-03T16:40:10Z",1238 "links": [{1239 "href": "http://openstack.ex.com/v2/openstack/images/"1240 "34yhwr-4t3q",1241 "rel": "self"}],1242 "created": "2014-10-30T08:23:39Z",1243 "minDisk": 0,1244 "minRam": 0,1245 "progress": 0,1246 "metadata": {},1247 },1248 {1249 "status": "ACTIVE",1250 "name": "cirros-0.3.2-x86_64-disk",1251 "id": "1bea47ed-f6a9",1252 "updated": "2014-11-03T16:40:10Z",1253 "links": [{1254 "href": "http://openstack.ex.com/v2/openstack/images/"1255 "1bea47ed-f6a9",1256 "rel": "self"}],1257 "created": "2014-10-30T08:23:39Z",1258 "minDisk": 0,1259 "minRam": 0,1260 "progress": 0,1261 "metadata": {},1262 }1263 ]1264 }1265 def test_delete_fail(self):1266 delete_mock = [(self.get_method, self.response, 200),1267 (self.delete_method, 'error', None),1268 (self.log_method, 'exception', None)]1269 self._test_delete(delete_mock, fail=True)1270 def test_delete_pass(self):1271 delete_mock = [(self.get_method, self.response, 200),1272 (self.delete_method, None, 204),1273 (self.log_method, 'exception', None)]1274 self._test_delete(delete_mock)1275 def test_dry_run(self):1276 dry_mock = [(self.get_method, self.response, 200),1277 (self.delete_method, "delete", None)]1278 self._test_dry_run_true(dry_mock)1279 def test_save_state(self):1280 self._test_saved_state_true([(self.get_method, self.response, 200)])1281 def test_preserve_list(self):1282 self.response['images'].append(1283 {1284 "status": "ACTIVE",1285 "name": "cirros-0.3.2-x86_64-disk",1286 "id": cleanup_service.CONF_IMAGES[0],1287 "updated": "2014-11-03T16:40:10Z",1288 "links": [{1289 "href": "http://openstack.ex.com/v2/openstack/images/"1290 "None",1291 "rel": "self"}],1292 "created": "2014-10-30T08:23:39Z",1293 "minDisk": 0,1294 "minRam": 0,1295 "progress": 0,1296 "metadata": {},1297 })1298 self._test_is_preserve_true([(self.get_method, self.response, 200)])1299class TestFlavorService(BaseCmdServiceTests):1300 service_class = 'FlavorService'1301 service_name = 'flavors'1302 response = {1303 "flavors": [1304 {1305 "disk": 1,1306 "id": "42",1307 "links": [{1308 "href": "http://openstack.ex.com/v2/openstack/flavors/1",1309 "rel": "self"}, {1310 "href": "http://openstack.ex.com/openstack/flavors/1",1311 "rel": "bookmark"}],1312 "name": "m1.tiny",1313 "ram": 512,1314 "swap": 1,1315 "vcpus": 11316 },1317 {1318 "disk": 2,1319 "id": "13",1320 "links": [{1321 "href": "http://openstack.ex.com/v2/openstack/flavors/2",1322 "rel": "self"}, {1323 "href": "http://openstack.ex.com/openstack/flavors/2",1324 "rel": "bookmark"}],1325 "name": "m1.tiny",1326 "ram": 512,1327 "swap": 1,1328 "vcpus": 11329 }1330 ]1331 }1332 def test_delete_fail(self):1333 delete_mock = [(self.get_method, self.response, 200),1334 (self.delete_method, 'error', None),1335 (self.log_method, 'exception', None)]1336 self._test_delete(delete_mock, fail=True)1337 def test_delete_pass(self):1338 delete_mock = [(self.get_method, self.response, 200),1339 (self.delete_method, None, 202),1340 (self.log_method, 'exception', None)]1341 self._test_delete(delete_mock)1342 def test_dry_run(self):1343 dry_mock = [(self.get_method, self.response, 200),1344 (self.delete_method, "delete", None)]1345 self._test_dry_run_true(dry_mock)1346 def test_save_state(self):1347 self._test_saved_state_true([(self.get_method, self.response, 200)])1348 def test_preserve_list(self):1349 self.response['flavors'].append(1350 {1351 "disk": 3,1352 "id": cleanup_service.CONF_FLAVORS[0],1353 "links": [{1354 "href": "http://openstack.ex.com/v2/openstack/flavors/3",1355 "rel": "self"}, {1356 "href": "http://openstack.ex.com/openstack/flavors/3",1357 "rel": "bookmark"}],1358 "name": "m1.tiny",1359 "ram": 512,1360 "swap": 1,1361 "vcpus": 11362 })1363 self._test_is_preserve_true([(self.get_method, self.response, 200)])1364class TestRoleService(BaseCmdServiceTests):1365 service_class = 'RoleService'1366 service_name = 'roles'1367 response = {1368 "roles": [1369 {1370 "domain_id": "FakeDomain",1371 "id": "3efrt74r45hn",1372 "name": "president",1373 "links": {1374 "self": "http://ex.com/identity/v3/roles/3efrt74r45hn"1375 }1376 },1377 {1378 "domain_id": 'FakeDomain',1379 "id": "39ruo5sdk040",1380 "name": "vice-p",1381 "links": {1382 "self": "http://ex.com/identity/v3/roles/39ruo5sdk040"1383 }1384 }1385 ]1386 }1387 def test_delete_fail(self):1388 delete_mock = [(self.get_method, self.response, 200),1389 (self.delete_method, 'error', None),1390 (self.log_method, 'exception', None)]1391 self._test_delete(delete_mock, fail=True)1392 def test_delete_pass(self):1393 delete_mock = [(self.get_method, self.response, 200),1394 (self.delete_method, None, 204),1395 (self.log_method, 'exception', None)]1396 self._test_delete(delete_mock)1397 def test_dry_run(self):1398 dry_mock = [(self.get_method, self.response, 200),1399 (self.delete_method, "delete", None)]1400 self._test_dry_run_true(dry_mock)1401 def test_save_state(self):1402 self._test_saved_state_true([(self.get_method, self.response, 200)])1403class TestUserService(BaseCmdServiceTests):1404 service_class = 'UserService'1405 service_name = 'users'1406 response = {1407 "users": [1408 {1409 "domain_id": "TempestDomain",1410 "enabled": True,1411 "id": "e812fb332456423fdv1b1320121qwe2",1412 "links": {1413 "self": "http://example.com/identity/v3/users/"1414 "e812fb332456423fdv1b1320121qwe2",1415 },1416 "name": "Thunder",1417 "password_expires_at": "3102-11-06T15:32:17.000000",1418 },1419 {1420 "domain_id": "TempestDomain",1421 "enabled": True,1422 "id": "32rwef64245tgr20121qw324bgg",1423 "links": {1424 "self": "http://example.com/identity/v3/users/"1425 "32rwef64245tgr20121qw324bgg",1426 },1427 "name": "Lightning",1428 "password_expires_at": "1893-11-06T15:32:17.000000",1429 }1430 ]1431 }1432 def test_delete_fail(self):1433 delete_mock = [(self.get_method, self.response, 200),1434 (self.delete_method, 'error', None),1435 (self.log_method, 'exception', None)]1436 self._test_delete(delete_mock, fail=True)1437 def test_delete_pass(self):1438 delete_mock = [(self.get_method, self.response, 200),1439 (self.delete_method, None, 204),1440 (self.log_method, 'exception', None)]1441 self._test_delete(delete_mock)1442 def test_dry_run(self):1443 dry_mock = [(self.get_method, self.response, 200),1444 (self.delete_method, "delete", None)]1445 self._test_dry_run_true(dry_mock)1446 def test_save_state(self):1447 self._test_saved_state_true([(self.get_method, self.response, 200)])1448 def test_preserve_list(self):1449 self.response['users'].append(1450 {1451 "domain_id": "TempestDomain",...

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