How to use create_server method in avocado

Best Python code snippet using avocado_python

test_servers_negative.py

Source:test_servers_negative.py Github

copy

Full Screen

...69 self.create_server, accessIPv6=IPv6)70 @attr(type='negative')71 def test_reboot_deleted_server(self):72 # Reboot a deleted server73 resp, server = self.create_server()74 self.server_id = server['id']75 self.client.delete_server(self.server_id)76 self.client.wait_for_server_termination(self.server_id)77 self.assertRaises(exceptions.NotFound, self.client.reboot,78 self.server_id, 'SOFT')79 @attr(type='negative')80 def test_rebuild_deleted_server(self):81 # Rebuild a deleted server82 resp, server = self.create_server()83 self.server_id = server['id']84 self.client.delete_server(self.server_id)85 self.client.wait_for_server_termination(self.server_id)86 self.assertRaises(exceptions.NotFound,87 self.client.rebuild,88 self.server_id, self.image_ref_alt)89 @attr(type='negative')90 def test_create_numeric_server_name(self):91 # Create a server with a numeric name92 if self.__class__._interface == "xml":93 raise self.skipException("Not testable in XML")94 server_name = 1234595 self.assertRaises(exceptions.BadRequest,96 self.create_server,97 name=server_name)98 @attr(type='negative')99 def test_create_server_name_length_exceeds_256(self):100 # Create a server with name length exceeding 256 characters101 server_name = 'a' * 256102 self.assertRaises(exceptions.BadRequest,103 self.create_server,104 name=server_name)105 @attr(type='negative')106 def test_create_with_invalid_network_uuid(self):107 # Pass invalid network uuid while creating a server108 networks = [{'fixed_ip': '10.0.1.1', 'uuid': 'a-b-c-d-e-f-g-h-i-j'}]109 self.assertRaises(exceptions.BadRequest,110 self.create_server,111 networks=networks)112 @attr(type='negative')113 def test_create_with_non_existant_keypair(self):114 # Pass a non existant keypair while creating a server115 key_name = rand_name('key')116 self.assertRaises(exceptions.BadRequest,117 self.create_server,118 key_name=key_name)119 @attr(type='negative')120 def test_create_server_metadata_exceeds_length_limit(self):121 # Pass really long metadata while creating a server122 metadata = {'a': 'b' * 260}123 self.assertRaises(exceptions.OverLimit,124 self.create_server,125 meta=metadata)126 @attr(type='negative')127 def test_update_name_of_non_existent_server(self):128 # Update name of a non-existent server129 server_name = rand_name('server')130 new_name = rand_name('server') + '_updated'131 self.assertRaises(exceptions.NotFound, self.client.update_server,132 server_name, name=new_name)133 @attr(type='negative')134 def test_update_server_set_empty_name(self):135 # Update name of the server to an empty string136 server_name = rand_name('server')137 new_name = ''138 self.assertRaises(exceptions.BadRequest, self.client.update_server,139 server_name, name=new_name)140 @attr(type='negative')141 def test_update_server_of_another_tenant(self):142 # Update name of a server that belongs to another tenant143 resp, server = self.create_server(wait_until='ACTIVE')144 new_name = server['id'] + '_new'145 self.assertRaises(exceptions.NotFound,146 self.alt_client.update_server, server['id'],147 name=new_name)148 @attr(type='negative')149 def test_update_server_name_length_exceeds_256(self):150 # Update name of server exceed the name length limit151 resp, server = self.create_server(wait_until='ACTIVE')152 new_name = 'a' * 256153 self.assertRaises(exceptions.BadRequest,154 self.client.update_server,155 server['id'],156 name=new_name)157 @attr(type='negative')158 def test_delete_non_existent_server(self):159 # Delete a non existent server160 self.assertRaises(exceptions.NotFound, self.client.delete_server,161 '999erra43')162 @attr(type='negative')163 def test_delete_a_server_of_another_tenant(self):164 # Delete a server that belongs to another tenant165 try:166 resp, server = self.create_server(wait_until='ACTIVE')167 self.assertRaises(exceptions.NotFound,168 self.alt_client.delete_server,169 server['id'])170 finally:171 self.client.delete_server(server['id'])172 @attr(type='negative')173 def test_delete_server_pass_negative_id(self):174 # Pass an invalid string parameter to delete server175 self.assertRaises(exceptions.NotFound, self.client.delete_server, -1)176 @attr(type='negative')177 def test_delete_server_pass_id_exceeding_length_limit(self):178 # Pass a server ID that exceeds length limit to delete server179 self.assertRaises(exceptions.NotFound, self.client.delete_server,180 sys.maxint + 1)...

Full Screen

Full Screen

test_api.py

Source:test_api.py Github

copy

Full Screen

...5from . import WEBHOOKDATA, success, load_data6def test_server_new(tester, create_server):7 resp = tester.post('/api/server/new', data={})8 assert not success(resp)9 server = create_server()10 assert server['ip'] == '127.0.0.1'11def test_server_delete(tester, create_server, sql):12 server = create_server()13 resp = tester.post('/api/server/delete', data={'server_id': server['id']})14 assert success(resp)15 text = 'select count(*) from server where !deleted'16 assert sql.execute(text).scalar() == 017def test_server_list(tester, create_server):18 create_server()19 create_server()20 resp = tester.get('/api/server/list')21 assert success(resp)22 assert len(load_data(resp)) == 223def test_webhoot_new(tester, create_server, create_webhook):24 server = create_server()25 webhook = create_webhook(server_id=server['id'])26 assert webhook['branch'] == 'master'27 webhook = create_webhook(server_id=server['id'],28 webhook_id=webhook['id'], branch='dev')29 assert webhook['branch'] == 'dev'30def test_webhoot_delete(tester, create_server, create_webhook, sql):31 server = create_server()32 webhook = create_webhook(server_id=server['id'])33 data = {'webhook_id': webhook['id']}34 resp = tester.post('/api/webhook/delete', data=data)35 assert success(resp)36 text = 'select count(*) from web_hook where !deleted'37 assert sql.execute(text).scalar() == 038def test_webhook_list(tester, create_server, create_webhook):39 server = create_server()40 create_webhook(server_id=server['id'])41 create_webhook(server_id=server['id'])42 resp = tester.get('/api/webhook/list')43 assert success(resp)44 assert len(load_data(resp)) == 245def test_history(tester, create_server, create_webhook, sql):46 server = create_server()47 webhook = create_webhook(server_id=server['id'])48 query_string = {'webhook_id': webhook['id']}49 resp = tester.get('/api/history/list', query_string=query_string)50 assert len(load_data(resp)['histories']) == 051 history = model.History(52 status='1',53 webhook_id=webhook['id'],54 data='null'55 )56 sql.add(history)57 sql.commit()58 resp = tester.get('/api/history/list', query_string=query_string)59 assert len(load_data(resp)['histories']) == 160@pytest.mark.parametrize("name,data", WEBHOOKDATA.items())61def test_git_webhook(tester, create_server, create_webhook, name, data):62 server = create_server()63 webhook = create_webhook(server_id=server['id'])64 url = '/api/git-webhook/{}'.format(webhook['key'])65 resp = tester.post(url, data=json.dumps(data))...

Full Screen

Full Screen

test_server.py

Source:test_server.py Github

copy

Full Screen

1import unittest2from server import create_server3class TestStringMethods(unittest.TestCase):4 def test_urls(self):5 self.assertEqual(create_server.check_file_type("/"), True)6 self.assertEqual(create_server.check_file_type("/foo"), True)7 self.assertEqual(create_server.check_file_type("foo"), False)8 self.assertEqual(create_server.check_file_type("foo/"), False)9 self.assertEqual(create_server.check_file_type(""), False)10 self.assertEqual(create_server.check_file_type("/."), False)11 self.assertEqual(create_server.check_file_type("./"), False)12 self.assertEqual(create_server.check_file_type("/./"), False)13 self.assertEqual(create_server.check_file_type("/../"), False)14 self.assertEqual(create_server.check_file_type("/.."), False)15 self.assertEqual(create_server.check_file_type("//"), False)16 self.assertEqual(create_server.check_file_type("/f"), True)17 self.assertEqual(create_server.check_file_type("/"), True)18 self.assertEqual(create_server.check_file_type("/f./"), False)19 self.assertEqual(create_server.check_file_type("/f.f"), False)20 self.assertEqual(create_server.check_file_type("/f.f/"), False)21 self.assertEqual(create_server.check_file_type("/f../"), False)22 self.assertEqual(create_server.check_file_type("/f.txt/"), False)23 self.assertEqual(create_server.check_file_type("/f.htm/"), False)24 self.assertEqual(create_server.check_file_type("/f.html/"), False)25 self.assertEqual(create_server.check_file_type("/f.txt"), True)26 self.assertEqual(create_server.check_file_type("/f.htm"), True)27 self.assertEqual(create_server.check_file_type("/f.html"), True)28 self.assertEqual(create_server.check_file_type("/f.jpg/"), False)29 self.assertEqual(create_server.check_file_type("/f.jpg"), False)30if __name__ == '__main__':...

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