Best Python code snippet using tempest_python
test_test.py
Source:test_test.py  
...629        super(TestAPIMicroversionTest1, cls).resource_setup()630        # Setting microvesions and checks that every tests631        # of this class will have those microversion set632        # on service clients requesting service APIs.633        cls.setup_api_microversion_fixture(634            compute_microversion='2.30',635            volume_microversion='3.10',636            placement_microversion='3.1')637        # Check microvesion is set during resource_setup()638        if base_compute_client.COMPUTE_MICROVERSION != '2.30':639            raise testtools.TestCase.failureException(640                "Microversion is not set in resource_setup method")641        if base_volume_client.VOLUME_MICROVERSION != '3.10':642            raise testtools.TestCase.failureException(643                "Microversion is not set in resource_setup method")644        if base_placement_client.PLACEMENT_MICROVERSION != '3.1':645            raise testtools.TestCase.failureException(646                "Microversion is not set in resource_setup method")647    @classmethod648    def resource_cleanup(cls):649        super(TestAPIMicroversionTest1, cls).resource_cleanup()650        # Check microversion is reset back to None in resource_cleanup()651        if base_compute_client.COMPUTE_MICROVERSION is not None:652            raise testtools.TestCase.failureException(653                "Microversion is not reset to None in resource_cleanup method")654        if base_volume_client.VOLUME_MICROVERSION is not None:655            raise testtools.TestCase.failureException(656                "Microversion is not reset to None in resource_cleanup method")657        if base_placement_client.PLACEMENT_MICROVERSION is not None:658            raise testtools.TestCase.failureException(659                "Microversion is not reset to None in resource_cleanup method")660    def setUp(self):661        super(TestAPIMicroversionTest1, self).setUp()662        # Check microversion is set in setUp method also.663        self.assertEqual('2.30', base_compute_client.COMPUTE_MICROVERSION)664        self.assertEqual('3.10', base_volume_client.VOLUME_MICROVERSION)665        self.assertEqual('3.1', base_placement_client.PLACEMENT_MICROVERSION)666    def tearDown(self):667        super(TestAPIMicroversionTest1, self).tearDown()668        # Check microversion is set in tearDown method also.669        self.assertEqual('2.30', base_compute_client.COMPUTE_MICROVERSION)670        self.assertEqual('3.10', base_volume_client.VOLUME_MICROVERSION)671        self.assertEqual('3.1', base_placement_client.PLACEMENT_MICROVERSION)672    def test_1(self):673        self.assertEqual('2.30', base_compute_client.COMPUTE_MICROVERSION)674        self.assertEqual('3.10', base_volume_client.VOLUME_MICROVERSION)675        self.assertEqual('3.1', base_placement_client.PLACEMENT_MICROVERSION)676    def test_2(self):677        self.assertEqual('2.30', base_compute_client.COMPUTE_MICROVERSION)678        self.assertEqual('3.10', base_volume_client.VOLUME_MICROVERSION)679        self.assertEqual('3.1', base_placement_client.PLACEMENT_MICROVERSION)680class TestAPIMicroversionTest2(test.BaseTestCase):681    @classmethod682    def resource_setup(cls):683        super(TestAPIMicroversionTest2, cls).resource_setup()684        # Setting microvesions different from what set in685        # MicroversionTest1 and checks that every tests686        # of this class will have the new microversion set687        # on service clients requesting service APIs.688        cls.setup_api_microversion_fixture(689            compute_microversion='2.80',690            volume_microversion='3.80',691            placement_microversion='3.8')692        # Check microvesion is set during resource_setup()693        if base_compute_client.COMPUTE_MICROVERSION != '2.80':694            raise testtools.TestCase.failureException(695                "Microversion is not set in resource_setup method")696        if base_volume_client.VOLUME_MICROVERSION != '3.80':697            raise testtools.TestCase.failureException(698                "Microversion is not set in resource_setup method")699        if base_placement_client.PLACEMENT_MICROVERSION != '3.8':700            raise testtools.TestCase.failureException(701                "Microversion is not set in resource_setup method")702    @classmethod...test.py
Source:test.py  
...393                    cls.servers_alt.show_server(vm_alt['id'])394        """395        pass396    @classmethod397    def setup_api_microversion_fixture(398            cls, compute_microversion=None, volume_microversion=None,399            placement_microversion=None):400        """Set up api microversion fixture on service clients.401        `setup_api_microversion_fixture` is used to set the api microversion402        on service clients. This can be invoked from resource_setup() method.403        Example::404            @classmethod405            def resource_setup(cls):406                super(MyTest, cls).resource_setup()407                cls.setup_api_microversion_fixture(408                    compute_microversion=cls.compute_request_microversion,409                    volume_microversion=cls.volume_request_microversion,410                    placement_microversion=cls.placement_request_microversion)411        """412        api_fixture = api_microversion_fixture.APIMicroversionFixture(413            compute_microversion=compute_microversion,414            volume_microversion=volume_microversion,415            placement_microversion=placement_microversion)416        api_fixture.setUp()417        cls.addClassResourceCleanup(api_fixture._reset_microversion)418    @classmethod419    def resource_setup(cls):420        """Class level resource setup for test cases.421        `resource_setup` is invoked once all credentials (and related network...base.py
Source:base.py  
...71        cls.compute_request_microversion = (72            api_version_utils.select_request_microversion(73                cls.min_microversion,74                CONF.compute.min_microversion))75        cls.setup_api_microversion_fixture(76            compute_microversion=cls.compute_request_microversion,77            volume_microversion=cls.volume_request_microversion)78        cls.image_ref = CONF.compute.image_ref79        cls.flavor_ref = CONF.compute.flavor_ref80        cls.build_interval = CONF.volume.build_interval81        cls.build_timeout = CONF.volume.build_timeout82    @classmethod83    def create_volume(cls, wait_until='available', **kwargs):84        """Wrapper utility that returns a test volume.85           :param wait_until: wait till volume status, None means no wait.86        """87        if 'size' not in kwargs:88            kwargs['size'] = CONF.volume.volume_size89        if 'imageRef' in kwargs:...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!!
