Best Python code snippet using tempest_python
test_servers.py
Source:test_servers.py  
...378            self.os.nova.poll_request_status('GET', url, 404)379        except exceptions.TimeoutException:380            self.fail("Server deletion timed out")381    test_delete_while_building.tags = ['nova']382    def test_create_with_invalid_image(self):383        """Create a server with an unknown image"""384        post_body = json.dumps({385            'server' : {386                'name' : 'testserver',387                'imageRef' : -1,388                'flavorRef' : self.flavor_ref,389            }390        })391        resp, body = self.os.nova.request('POST', '/servers', body=post_body)392        self.assertEqual(400, resp.status)393        fault = json.loads(body)394        expected_fault = {395            "badRequest": {396                "message": "Cannot find requested image",...test_servers_negative.py
Source:test_servers_negative.py  
...43        self.assertRaises(exceptions.BadRequest,44                          self.create_server,45                          personality=person)46    @attr(type='negative')47    def test_create_with_invalid_image(self):48        # Create a server with an unknown image49        self.assertRaises(exceptions.BadRequest,50                          self.create_server,51                          image_id=-1)52    @attr(type='negative')53    def test_create_with_invalid_flavor(self):54        # Create a server with an unknown flavor55        self.assertRaises(exceptions.BadRequest,56                          self.create_server,57                          flavor=-1,)58    @attr(type='negative')59    def test_invalid_access_ip_v4_address(self):60        # An access IPv4 address must match a valid address pattern61        IPv4 = '1.1.1.1.1.1'...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!!
