Best Python code snippet using tempest_python
test_cleanup_services.py
Source:test_cleanup_services.py
...524 (self.delete_method, "delete", None)]525 self._test_dry_run_true(dry_mock)526 def test_save_state(self):527 self._test_saved_state_true([(self.get_method, self.response, 200)])528 def test_preserve_list(self):529 self.response['networks'].append(530 {531 "admin_state_up": True,532 "availability_zone_hints": [],533 "availability_zones": [534 "nova"535 ],536 "created_at": "2017-03-08T20:19:41",537 "dns_domain": "my-domain.org.",538 "id": cleanup_service.CONF_PUB_NETWORK,539 "name": "net2",540 "port_security_enabled": True,541 "project_id": "4fd44f30292945e481c7b8a0c8908869",542 "qos_policy_id": "6a8454ade84346f59e8d40665f878b2e",543 "revision_number": 1,544 "status": "ACTIVE",545 "subnets": [546 "54d6f61d-db07-451c-9ab3-b9609b6b6f0b"547 ],548 "tenant_id": "4fd44f30292945e481c7b8a0c8908869",549 "updated_at": "2018-03-08T20:19:41",550 "vlan_transparent": True,551 "is_default": False552 })553 self._test_is_preserve_true([(self.get_method, self.response, 200)])554class TestNetworkFloatingIpService(BaseCmdServiceTests):555 service_class = 'NetworkFloatingIpService'556 service_name = 'floatingips'557 response = {558 "floatingips": [559 {560 "router_id": "d23abc8d-2991-4a55-ba98-2aaea84cc72f",561 "description": "for test",562 "dns_domain": "my-domain.org.",563 "dns_name": "myfip",564 "created_at": "2016-12-21T10:55:50Z",565 "updated_at": "2016-12-21T10:55:53Z",566 "revision_number": 1,567 "project_id": "4969c491a3c74ee4af974e6d800c62de",568 "tenant_id": "4969c491a3c74ee4af974e6d800c62de",569 "floating_network_id": "376da547-b977-4cfe-9cba-275c80debf57",570 "fixed_ip_address": "10.0.0.3",571 "floating_ip_address": "172.24.4.228",572 "port_id": "ce705c24-c1ef-408a-bda3-7bbd946164ab",573 "id": "2f245a7b-796b-4f26-9cf9-9e82d248fda7",574 "status": "ACTIVE",575 "port_details": {576 "status": "ACTIVE",577 "name": "",578 "admin_state_up": True,579 "network_id": "02dd8479-ef26-4398-a102-d19d0a7b3a1f",580 "device_owner": "compute:nova",581 "mac_address": "fa:16:3e:b1:3b:30",582 "device_id": "8e3941b4-a6e9-499f-a1ac-2a4662025cba"583 },584 "tags": ["tag1,tag2"],585 "port_forwardings": []586 },587 {588 "id": "9e82d248-408a",589 "status": "ACTIVE"590 }591 ]592 }593 def test_delete_fail(self):594 delete_mock = [(self.get_method, self.response, 200),595 (self.delete_method, 'error', None),596 (self.log_method, 'exception', None)]597 self._test_delete(delete_mock, fail=True)598 def test_delete_pass(self):599 delete_mock = [(self.get_method, self.response, 200),600 (self.delete_method, None, 204),601 (self.log_method, 'exception', None)]602 self._test_delete(delete_mock)603 def test_dry_run(self):604 dry_mock = [(self.get_method, self.response, 200),605 (self.delete_method, "delete", None)]606 self._test_dry_run_true(dry_mock)607 def test_save_state(self):608 self._test_saved_state_true([(self.get_method, self.response, 200)])609class TestNetworkRouterService(BaseCmdServiceTests):610 service_class = 'NetworkRouterService'611 service_name = 'routers'612 validate_response = ('tempest.lib.services.network.routers_client'613 '.RoutersClient.validate_response')614 response = {615 "routers": [616 {617 "admin_state_up": True,618 "availability_zone_hints": [],619 "availability_zones": [620 "nova"621 ],622 "created_at": "2018-03-19T19:17:04Z",623 "description": "",624 "distributed": False,625 "external_gateway_info": {626 "enable_snat": True,627 "external_fixed_ips": [628 {629 "ip_address": "172.24.4.3",630 "subnet_id": "b930d7f6-ceb7-40a0-8b81-a425dd994ccf"631 },632 {633 "ip_address": "2001:db8::c",634 "subnet_id": "0c56df5d-ace5-46c8-8f4c-45fa4e334d18"635 }636 ],637 "network_id": "ae34051f-aa6c-4c75-abf5-50dc9ac99ef3"638 },639 "flavor_id": "f7b14d9a-b0dc-4fbe-bb14-a0f4970a69e0",640 "ha": False,641 "id": "915a14a6-867b-4af7-83d1-70efceb146f9",642 "name": "router2",643 "revision_number": 1,644 "routes": [645 {646 "destination": "179.24.1.0/24",647 "nexthop": "172.24.3.99"648 }649 ],650 "status": "ACTIVE",651 "updated_at": "2018-03-19T19:17:22Z",652 "project_id": "0bd18306d801447bb457a46252d82d13",653 "tenant_id": "0bd18306d801447bb457a46252d82d13",654 "tags": ["tag1,tag2"]655 },656 {657 "id": "4s5w34hj-id44",658 "name": "saved-router"659 }660 ],661 # "ports" key is added to the response in order to simplify unit662 # testing - it's because NetworkRouterService's delete method lists663 # ports before deleting any router664 "ports": []665 }666 def _test_delete(self, mocked_fixture_tuple_list, fail=False):667 serv = self._create_cmd_service(self.service_class)668 resp, fixtures = self.run_function_with_mocks(669 serv.run,670 mocked_fixture_tuple_list,671 )672 for fixture in fixtures:673 if fail is False and fixture.mock.return_value == 'exception':674 fixture.mock.assert_not_called()675 elif self.service_name in self.saved_state.keys():676 fixture.mock.assert_called()677 for key in self.saved_state[self.service_name].keys():678 self.assertNotIn(key, fixture.mock.call_args[0][0])679 self.assertFalse(serv.data)680 def test_delete_fail(self):681 delete_mock = [(self.get_method, self.response, 200),682 (self.delete_method, 'error', None),683 (self.log_method, 'exception', None)]684 self._test_delete(delete_mock, fail=True)685 def test_delete_pass(self):686 delete_mock = [(self.get_method, self.response, 200),687 (self.delete_method, None, 204),688 (self.log_method, 'exception', None)]689 self._test_delete(delete_mock)690 def test_dry_run(self):691 dry_mock = [(self.get_method, self.response, 200),692 (self.delete_method, "delete", None)]693 self._test_dry_run_true(dry_mock)694 def test_save_state(self):695 self._test_saved_state_true([(self.get_method, self.response, 200)])696 def test_preserve_list(self):697 self.response['routers'].append(698 {699 "admin_state_up": True,700 "availability_zone_hints": [],701 "availability_zones": [702 "nova"703 ],704 "created_at": "2018-03-19T19:17:04Z",705 "id": cleanup_service.CONF_PUB_ROUTER,706 "name": "router-preserve",707 "status": "ACTIVE",708 "updated_at": "2018-03-19T19:17:22Z",709 "project_id": "0bd18306d801447bb457a46252d82d13",710 "tenant_id": "0bd18306d801447bb457a46252d82d13",711 "tags": ["tag1,tag2"]712 })713 self._test_is_preserve_true([(self.get_method, self.response, 200)])714class TestNetworkMeteringLabelRuleService(BaseCmdServiceTests):715 service_class = 'NetworkMeteringLabelRuleService'716 service_name = 'metering_label_rules'717 response = {718 "metering_label_rules": [719 {720 "remote_ip_prefix": "20.0.0.0/24",721 "direction": "ingress",722 "metering_label_id": "e131d186-b02d-4c0b-83d5-0c0725c4f812",723 "id": "9536641a-7d14-4dc5-afaf-93a973ce0eb8",724 "excluded": False725 },726 {727 "direction": "ingress",728 "id": "93a973ce-4dc5"729 }730 ]731 }732 def test_delete_fail(self):733 delete_mock = [(self.get_method, self.response, 200),734 (self.delete_method, 'error', None),735 (self.log_method, 'exception', None)]736 self._test_delete(delete_mock, fail=True)737 def test_delete_pass(self):738 delete_mock = [(self.get_method, self.response, 200),739 (self.delete_method, None, 204),740 (self.log_method, 'exception', None)]741 self._test_delete(delete_mock)742 def test_dry_run(self):743 dry_mock = [(self.get_method, self.response, 200),744 (self.delete_method, "delete", None)]745 self._test_dry_run_true(dry_mock)746 def test_save_state(self):747 self._test_saved_state_true([(self.get_method, self.response, 200)])748class TestNetworkMeteringLabelService(BaseCmdServiceTests):749 service_class = 'NetworkMeteringLabelService'750 service_name = 'metering_labels'751 response = {752 "metering_labels": [753 {754 "project_id": "45345b0ee1ea477fac0f541b2cb79cd4",755 "tenant_id": "45345b0ee1ea477fac0f541b2cb79cd4",756 "description": "label1 description",757 "name": "label1",758 "id": "a6700594-5b7a-4105-8bfe-723b346ce866",759 "shared": False760 },761 {762 "name": "saved-label",763 "id": "723b346ce866-4c7q",764 }765 ]766 }767 def test_delete_fail(self):768 delete_mock = [(self.get_method, self.response, 200),769 (self.delete_method, 'error', None),770 (self.log_method, 'exception', None)]771 self._test_delete(delete_mock, fail=True)772 def test_delete_pass(self):773 delete_mock = [(self.get_method, self.response, 200),774 (self.delete_method, None, 204),775 (self.log_method, 'exception', None)]776 self._test_delete(delete_mock)777 def test_dry_run(self):778 dry_mock = [(self.get_method, self.response, 200),779 (self.delete_method, "delete", None)]780 self._test_dry_run_true(dry_mock)781 def test_save_state(self):782 self._test_saved_state_true([(self.get_method, self.response, 200)])783class TestNetworkPortService(BaseCmdServiceTests):784 service_class = 'NetworkPortService'785 service_name = 'ports'786 response = {787 "ports": [788 {789 "admin_state_up": True,790 "allowed_address_pairs": [],791 "created_at": "2016-03-08T20:19:41",792 "description": "",793 "device_id": "9ae135f4-b6e0-4dad-9e91-3c223e385824",794 "device_owner": "",795 "dns_assignment": {796 "hostname": "myport",797 "ip_address": "172.24.4.2",798 "fqdn": "myport.my-domain.org"799 },800 "dns_domain": "my-domain.org.",801 "dns_name": "myport",802 "extra_dhcp_opts": [803 {804 "opt_value": "pxelinux.0",805 "ip_version": 4,806 "opt_name": "bootfile-name"807 }808 ],809 "fixed_ips": [810 {811 "ip_address": "172.24.4.2",812 "subnet_id": "008ba151-0b8c-4a67-98b5-0d2b87666062"813 }814 ],815 "id": "d80b1a3b-4fc1-49f3-952e-1e2ab7081d8b",816 "ip_allocation": "immediate",817 "mac_address": "fa:16:3e:58:42:ed",818 "name": "test_port",819 "network_id": "70c1db1f-b701-45bd-96e0-a313ee3430b3",820 "project_id": "",821 "revision_number": 1,822 "security_groups": [],823 "status": "ACTIVE",824 "tags": ["tag1,tag2"],825 "tenant_id": "",826 "updated_at": "2016-03-08T20:19:41",827 "qos_policy_id": "29d5e02e-d5ab-4929-bee4-4a9fc12e22ae",828 "port_security_enabled": False829 },830 {831 "id": "aa74aa4v-741a",832 "name": "saved-port",833 "device_owner": ""834 }835 ]836 }837 def test_delete_fail(self):838 delete_mock = [(self.get_method, self.response, 200),839 (self.delete_method, 'error', None),840 (self.log_method, 'exception', None)]841 self._test_delete(delete_mock, fail=True)842 def test_delete_pass(self):843 delete_mock = [(self.get_method, self.response, 200),844 (self.delete_method, None, 204),845 (self.log_method, 'exception', None)]846 self._test_delete(delete_mock)847 def test_dry_run(self):848 dry_mock = [(self.get_method, self.response, 200),849 (self.delete_method, "delete", None)]850 self._test_dry_run_true(dry_mock)851 def test_save_state(self):852 self._test_saved_state_true([(self.get_method, self.response, 200)])853 def test_preserve_list(self):854 self.response['ports'].append(855 {856 "created_at": "2018-03-08T20:19:41",857 "description": "",858 "device_id": "9ae135f4-b6e0-4dad-9e91-3c223e385824",859 "device_owner": "compute:router_gateway",860 "id": "d80b1a3b-4fc1-49f3-952e-1fdy1ws542",861 "ip_allocation": "immediate",862 "mac_address": "fa:16:3e:58:42:ed",863 "name": "preserve_port",864 "network_id": cleanup_service.CONF_PUB_NETWORK,865 "project_id": "",866 "security_groups": [],867 "status": "ACTIVE",868 "tags": ["tag1,tag2"],869 "tenant_id": "",870 "updated_at": "2018-03-08T20:19:41",871 })872 self._test_is_preserve_true([(self.get_method, self.response, 200)])873class TestNetworkSecGroupService(BaseCmdServiceTests):874 service_class = 'NetworkSecGroupService'875 service_name = 'security_groups'876 response = {877 "security_groups": [878 {879 "description": "default",880 "id": "85cc3048-abc3-43cc-89b3-377341426ac5",881 "name": "test",882 "security_group_rules": [883 {884 "direction": "egress",885 "ethertype": "IPv6",886 "id": "3c0e45ff-adaf-4124-b083-bf390e5482ff",887 "security_group_id": "85cc3048-abc3-43cc-89b3-3773414",888 "project_id": "e4f50856753b4dc6afee5fa6b9b6c550",889 "revision_number": 1,890 "tags": ["tag1,tag2"],891 "tenant_id": "e4f50856753b4dc6afee5fa6b9b6c550",892 "created_at": "2018-03-19T19:16:56Z",893 "updated_at": "2018-03-19T19:16:56Z",894 "description": ""895 }896 ]897 },898 {899 "id": "7q844add-3697",900 "name": "saved-sec-group"901 }902 ]903 }904 def test_delete_fail(self):905 delete_mock = [(self.get_method, self.response, 200),906 (self.delete_method, 'error', None),907 (self.log_method, 'exception', None)]908 self._test_delete(delete_mock, fail=True)909 def test_delete_pass(self):910 delete_mock = [(self.get_method, self.response, 200),911 (self.delete_method, None, 204),912 (self.log_method, 'exception', None)]913 self._test_delete(delete_mock)914 def test_dry_run(self):915 dry_mock = [(self.get_method, self.response, 200),916 (self.delete_method, "delete", None)]917 self._test_dry_run_true(dry_mock)918 def test_save_state(self):919 self._test_saved_state_true([(self.get_method, self.response, 200)])920 def test_preserve_list(self):921 self.response['security_groups'].append(922 {923 "description": "default",924 "id": "85cc3048-abc3-43cc-89b3-377341426ac5",925 "name": "test",926 "security_group_rules": [927 {928 "direction": "egress",929 "ethertype": "IPv6",930 "id": "3c0e45ff-adaf-4124-b083-bf390e5482ff",931 "security_group_id": "85cc3048-abc3-43cc-89b3-3773414",932 "project_id": cleanup_service.CONF_PROJECTS[0],933 "revision_number": 1,934 "tags": ["tag1,tag2"],935 "tenant_id": "e4f50856753b4dc6afee5fa6b9b6c550",936 "created_at": "2018-03-19T19:16:56Z",937 "updated_at": "2018-03-19T19:16:56Z",938 "description": ""939 }940 ]941 })942 self._test_is_preserve_true([(self.get_method, self.response, 200)])943class TestNetworkSubnetService(BaseCmdServiceTests):944 service_class = 'NetworkSubnetService'945 service_name = 'subnets'946 response = {947 "subnets": [948 {949 "name": "private-subnet",950 "enable_dhcp": True,951 "network_id": "db193ab3-96e3-4cb3-8fc5-05f4296d0324",952 "project_id": "26a7980765d0414dbc1fc1f88cdb7e6e",953 "tenant_id": "26a7980765d0414dbc1fc1f88cdb7e6e",954 "dns_nameservers": [],955 "allocation_pools": [956 {957 "start": "10.0.0.2",958 "end": "10.0.0.254"959 }960 ],961 "host_routes": [],962 "ip_version": 4,963 "gateway_ip": "10.0.0.1",964 "cidr": "10.0.0.0/24",965 "id": "08eae331-0402-425a-923c-34f7cfe39c1b",966 "created_at": "2016-10-10T14:35:34Z",967 "revision_number": 2,968 "service_types": [],969 "tags": ["tag1,tag2"],970 "updated_at": "2016-10-10T14:35:34Z"971 },972 {973 "id": "55ttda4a-2584",974 "name": "saved-subnet"975 }976 ]977 }978 def test_delete_fail(self):979 delete_mock = [(self.get_method, self.response, 200),980 (self.delete_method, 'error', None),981 (self.log_method, 'exception', None)]982 self._test_delete(delete_mock, fail=True)983 def test_delete_pass(self):984 delete_mock = [(self.get_method, self.response, 200),985 (self.delete_method, None, 204),986 (self.log_method, 'exception', None)]987 self._test_delete(delete_mock)988 def test_dry_run(self):989 dry_mock = [(self.get_method, self.response, 200),990 (self.delete_method, "delete", None)]991 self._test_dry_run_true(dry_mock)992 def test_save_state(self):993 self._test_saved_state_true([(self.get_method, self.response, 200)])994 def test_preserve_list(self):995 self.response['subnets'].append(996 {997 "name": "public-subnet",998 "network_id": cleanup_service.CONF_PUB_NETWORK,999 "project_id": "26a7980765d0414dbc1fc1f88cdb7e6e",1000 "tenant_id": "26a7980765d0414dbc1fc1f88cdb7e6e",1001 "ip_version": 4,1002 "gateway_ip": "10.0.0.1",1003 "cidr": "10.0.0.0/24",1004 "id": "08eae331-0402-425a-923c-34f7cfe39c1b",1005 "created_at": "2018-10-10T14:35:34Z",1006 "service_types": [],1007 "tags": ["tag1,tag2"],1008 "updated_at": "2018-10-10T14:35:34Z"1009 })1010 self._test_is_preserve_true([(self.get_method, self.response, 200)])1011class TestNetworkSubnetPoolsService(BaseCmdServiceTests):1012 service_class = 'NetworkSubnetPoolsService'1013 service_name = 'subnetpools'1014 response = {1015 "subnetpools": [1016 {1017 "min_prefixlen": "64",1018 "default_prefixlen": "64",1019 "id": "03f761e6-eee0-43fc-a921-8acf64c14988",1020 "max_prefixlen": "64",1021 "name": "my-subnet-pool-ipv6",1022 "is_default": False,1023 "project_id": "9fadcee8aa7c40cdb2114fff7d569c08",1024 "tenant_id": "9fadcee8aa7c40cdb2114fff7d569c08",1025 "prefixes": [1026 "2001:db8:0:2::/64",1027 "2001:db8::/63"1028 ],1029 "ip_version": 6,1030 "shared": False,1031 "description": "",1032 "created_at": "2016-03-08T20:19:41",1033 "updated_at": "2016-03-08T20:19:41",1034 "revision_number": 2,1035 "tags": ["tag1,tag2"]1036 },1037 {1038 "id": "8acf64c1-43fc",1039 "name": "saved-subnet-pool"1040 }1041 ]1042 }1043 def test_delete_fail(self):1044 delete_mock = [(self.get_method, self.response, 200),1045 (self.delete_method, 'error', None),1046 (self.log_method, 'exception', None)]1047 self._test_delete(delete_mock, fail=True)1048 def test_delete_pass(self):1049 delete_mock = [(self.get_method, self.response, 200),1050 (self.delete_method, None, 204),1051 (self.log_method, 'exception', None)]1052 self._test_delete(delete_mock)1053 def test_dry_run(self):1054 dry_mock = [(self.get_method, self.response, 200),1055 (self.delete_method, "delete", None)]1056 self._test_dry_run_true(dry_mock)1057 def test_save_state(self):1058 self._test_saved_state_true([(self.get_method, self.response, 200)])1059 def test_preserve_list(self):1060 self.response['subnetpools'].append(1061 {1062 "min_prefixlen": "64",1063 "default_prefixlen": "64",1064 "id": "9acf64c1-43fc",1065 "name": "preserve-pool",1066 "project_id": cleanup_service.CONF_PROJECTS[0],1067 "created_at": "2016-03-08T20:19:41",1068 "updated_at": "2016-03-08T20:19:41"1069 })1070 self._test_is_preserve_true([(self.get_method, self.response, 200)])1071# begin global services1072class TestDomainService(BaseCmdServiceTests):1073 service_class = 'DomainService'1074 service_name = 'domains'1075 response = {1076 "domains": [1077 {1078 "description": "Destroy all humans",1079 "enabled": True,1080 "id": "5a75994a3",1081 "links": {1082 "self": "http://example.com/identity/v3/domains/5a75994a3"1083 },1084 "name": "Sky_net"1085 },1086 {1087 "description": "Owns users and tenants on Identity API",1088 "enabled": False,1089 "id": "default",1090 "links": {1091 "self": "http://example.com/identity/v3/domains/default"1092 },1093 "name": "Default"1094 }1095 ]1096 }1097 mock_update = ("tempest.lib.services.identity.v3."1098 "domains_client.DomainsClient.update_domain")1099 def test_delete_fail(self):1100 delete_mock = [(self.get_method, self.response, 200),1101 (self.delete_method, 'error', None),1102 (self.log_method, 'exception', None),1103 (self.mock_update, 'update', None)]1104 self._test_delete(delete_mock, fail=True)1105 def test_delete_pass(self):1106 delete_mock = [(self.get_method, self.response, 200),1107 (self.delete_method, None, 204),1108 (self.log_method, 'exception', None),1109 (self.mock_update, 'update', None)]1110 self._test_delete(delete_mock)1111 def test_dry_run(self):1112 dry_mock = [(self.get_method, self.response, 200),1113 (self.delete_method, "delete", None)]1114 self._test_dry_run_true(dry_mock)1115 def test_save_state(self):1116 self._test_saved_state_true([(self.get_method, self.response, 200)])1117class TestProjectsService(BaseCmdServiceTests):1118 service_class = 'ProjectService'1119 service_name = 'projects'1120 response = {1121 "projects": [1122 {1123 "is_domain": False,1124 "description": None,1125 "domain_id": "default",1126 "enabled": True,1127 "id": "f38ohgp93jj032",1128 "links": {1129 "self": "http://example.com/identity/v3/projects"1130 "/f38ohgp93jj032"1131 },1132 "name": "manhattan",1133 "parent_id": None1134 },1135 {1136 "is_domain": False,1137 "description": None,1138 "domain_id": "default",1139 "enabled": True,1140 "id": "098f89d3292ri4jf4",1141 "links": {1142 "self": "http://example.com/identity/v3/projects"1143 "/098f89d3292ri4jf4"1144 },1145 "name": "Apollo",1146 "parent_id": None1147 }1148 ]1149 }1150 def test_delete_fail(self):1151 delete_mock = [(self.get_method, self.response, 200),1152 (self.delete_method, 'error', None),1153 (self.log_method, 'exception', None)]1154 self._test_delete(delete_mock, fail=True)1155 def test_delete_pass(self):1156 delete_mock = [(self.get_method, self.response, 200),1157 (self.delete_method, None, 204),1158 (self.log_method, 'exception', None)]1159 self._test_delete(delete_mock)1160 def test_dry_run(self):1161 dry_mock = [(self.get_method, self.response, 200),1162 (self.delete_method, "delete", None)]1163 self._test_dry_run_true(dry_mock)1164 def test_save_state(self):1165 self._test_saved_state_true([(self.get_method, self.response, 200)])1166 def test_preserve_list(self):1167 self.response['projects'].append(1168 {1169 "is_domain": False,1170 "description": None,1171 "domain_id": "default",1172 "enabled": True,1173 "id": "r343q98h09f3092",1174 "links": {1175 "self": "http://example.com/identity/v3/projects"1176 "/r343q98h09f3092"1177 },1178 "name": cleanup_service.CONF_PROJECTS[0],1179 "parent_id": None1180 })1181 self._test_is_preserve_true([(self.get_method, self.response, 200)])1182class TestImagesService(BaseCmdServiceTests):1183 service_class = 'ImageService'1184 service_name = 'images'1185 response = {1186 "images": [1187 {1188 "status": "ACTIVE",1189 "name": "stratus-0.3.2-x86_64-disk",1190 "id": "34yhwr-4t3q",1191 "updated": "2014-11-03T16:40:10Z",1192 "links": [{1193 "href": "http://openstack.ex.com/v2/openstack/images/"1194 "34yhwr-4t3q",1195 "rel": "self"}],1196 "created": "2014-10-30T08:23:39Z",1197 "minDisk": 0,1198 "minRam": 0,1199 "progress": 0,1200 "metadata": {},1201 },1202 {1203 "status": "ACTIVE",1204 "name": "cirros-0.3.2-x86_64-disk",1205 "id": "1bea47ed-f6a9",1206 "updated": "2014-11-03T16:40:10Z",1207 "links": [{1208 "href": "http://openstack.ex.com/v2/openstack/images/"1209 "1bea47ed-f6a9",1210 "rel": "self"}],1211 "created": "2014-10-30T08:23:39Z",1212 "minDisk": 0,1213 "minRam": 0,1214 "progress": 0,1215 "metadata": {},1216 }1217 ]1218 }1219 def test_delete_fail(self):1220 delete_mock = [(self.get_method, self.response, 200),1221 (self.delete_method, 'error', None),1222 (self.log_method, 'exception', None)]1223 self._test_delete(delete_mock, fail=True)1224 def test_delete_pass(self):1225 delete_mock = [(self.get_method, self.response, 200),1226 (self.delete_method, None, 204),1227 (self.log_method, 'exception', None)]1228 self._test_delete(delete_mock)1229 def test_dry_run(self):1230 dry_mock = [(self.get_method, self.response, 200),1231 (self.delete_method, "delete", None)]1232 self._test_dry_run_true(dry_mock)1233 def test_save_state(self):1234 self._test_saved_state_true([(self.get_method, self.response, 200)])1235 def test_preserve_list(self):1236 self.response['images'].append(1237 {1238 "status": "ACTIVE",1239 "name": "cirros-0.3.2-x86_64-disk",1240 "id": cleanup_service.CONF_IMAGES[0],1241 "updated": "2014-11-03T16:40:10Z",1242 "links": [{1243 "href": "http://openstack.ex.com/v2/openstack/images/"1244 "None",1245 "rel": "self"}],1246 "created": "2014-10-30T08:23:39Z",1247 "minDisk": 0,1248 "minRam": 0,1249 "progress": 0,1250 "metadata": {},1251 })1252 self._test_is_preserve_true([(self.get_method, self.response, 200)])1253class TestFlavorService(BaseCmdServiceTests):1254 service_class = 'FlavorService'1255 service_name = 'flavors'1256 response = {1257 "flavors": [1258 {1259 "disk": 1,1260 "id": "42",1261 "links": [{1262 "href": "http://openstack.ex.com/v2/openstack/flavors/1",1263 "rel": "self"}, {1264 "href": "http://openstack.ex.com/openstack/flavors/1",1265 "rel": "bookmark"}],1266 "name": "m1.tiny",1267 "ram": 512,1268 "swap": 1,1269 "vcpus": 11270 },1271 {1272 "disk": 2,1273 "id": "13",1274 "links": [{1275 "href": "http://openstack.ex.com/v2/openstack/flavors/2",1276 "rel": "self"}, {1277 "href": "http://openstack.ex.com/openstack/flavors/2",1278 "rel": "bookmark"}],1279 "name": "m1.tiny",1280 "ram": 512,1281 "swap": 1,1282 "vcpus": 11283 }1284 ]1285 }1286 def test_delete_fail(self):1287 delete_mock = [(self.get_method, self.response, 200),1288 (self.delete_method, 'error', None),1289 (self.log_method, 'exception', None)]1290 self._test_delete(delete_mock, fail=True)1291 def test_delete_pass(self):1292 delete_mock = [(self.get_method, self.response, 200),1293 (self.delete_method, None, 202),1294 (self.log_method, 'exception', None)]1295 self._test_delete(delete_mock)1296 def test_dry_run(self):1297 dry_mock = [(self.get_method, self.response, 200),1298 (self.delete_method, "delete", None)]1299 self._test_dry_run_true(dry_mock)1300 def test_save_state(self):1301 self._test_saved_state_true([(self.get_method, self.response, 200)])1302 def test_preserve_list(self):1303 self.response['flavors'].append(1304 {1305 "disk": 3,1306 "id": cleanup_service.CONF_FLAVORS[0],1307 "links": [{1308 "href": "http://openstack.ex.com/v2/openstack/flavors/3",1309 "rel": "self"}, {1310 "href": "http://openstack.ex.com/openstack/flavors/3",1311 "rel": "bookmark"}],1312 "name": "m1.tiny",1313 "ram": 512,1314 "swap": 1,1315 "vcpus": 11316 })1317 self._test_is_preserve_true([(self.get_method, self.response, 200)])1318class TestRoleService(BaseCmdServiceTests):1319 service_class = 'RoleService'1320 service_name = 'roles'1321 response = {1322 "roles": [1323 {1324 "domain_id": "FakeDomain",1325 "id": "3efrt74r45hn",1326 "name": "president",1327 "links": {1328 "self": "http://ex.com/identity/v3/roles/3efrt74r45hn"1329 }1330 },1331 {1332 "domain_id": 'FakeDomain',1333 "id": "39ruo5sdk040",1334 "name": "vice-p",1335 "links": {1336 "self": "http://ex.com/identity/v3/roles/39ruo5sdk040"1337 }1338 }1339 ]1340 }1341 def test_delete_fail(self):1342 delete_mock = [(self.get_method, self.response, 200),1343 (self.delete_method, 'error', None),1344 (self.log_method, 'exception', None)]1345 self._test_delete(delete_mock, fail=True)1346 def test_delete_pass(self):1347 delete_mock = [(self.get_method, self.response, 200),1348 (self.delete_method, None, 204),1349 (self.log_method, 'exception', None)]1350 self._test_delete(delete_mock)1351 def test_dry_run(self):1352 dry_mock = [(self.get_method, self.response, 200),1353 (self.delete_method, "delete", None)]1354 self._test_dry_run_true(dry_mock)1355 def test_save_state(self):1356 self._test_saved_state_true([(self.get_method, self.response, 200)])1357class TestUserService(BaseCmdServiceTests):1358 service_class = 'UserService'1359 service_name = 'users'1360 response = {1361 "users": [1362 {1363 "domain_id": "TempestDomain",1364 "enabled": True,1365 "id": "e812fb332456423fdv1b1320121qwe2",1366 "links": {1367 "self": "http://example.com/identity/v3/users/"1368 "e812fb332456423fdv1b1320121qwe2",1369 },1370 "name": "Thunder",1371 "password_expires_at": "3102-11-06T15:32:17.000000",1372 },1373 {1374 "domain_id": "TempestDomain",1375 "enabled": True,1376 "id": "32rwef64245tgr20121qw324bgg",1377 "links": {1378 "self": "http://example.com/identity/v3/users/"1379 "32rwef64245tgr20121qw324bgg",1380 },1381 "name": "Lightning",1382 "password_expires_at": "1893-11-06T15:32:17.000000",1383 }1384 ]1385 }1386 def test_delete_fail(self):1387 delete_mock = [(self.get_method, self.response, 200),1388 (self.delete_method, 'error', None),1389 (self.log_method, 'exception', None)]1390 self._test_delete(delete_mock, fail=True)1391 def test_delete_pass(self):1392 delete_mock = [(self.get_method, self.response, 200),1393 (self.delete_method, None, 204),1394 (self.log_method, 'exception', None)]1395 self._test_delete(delete_mock)1396 def test_dry_run(self):1397 dry_mock = [(self.get_method, self.response, 200),1398 (self.delete_method, "delete", None)]1399 self._test_dry_run_true(dry_mock)1400 def test_save_state(self):1401 self._test_saved_state_true([(self.get_method, self.response, 200)])1402 def test_preserve_list(self):1403 self.response['users'].append(1404 {1405 "domain_id": "TempestDomain",1406 "enabled": True,1407 "id": "23ads5tg3rtrhe30121qwhyth",1408 "links": {1409 "self": "http://example.com/identity/v3/users/"1410 "23ads5tg3rtrhe30121qwhyth",1411 },1412 "name": cleanup_service.CONF_USERS[0],1413 "password_expires_at": "1893-11-06T15:32:17.000000",1414 })...
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!!