Best Python code snippet using localstack_python
test_server.py
Source: test_server.py
...5from ao.upcloud import factories6from ao.core import fields7class ListServerTest(APITestCase):8 url = reverse('upcloud:server-list')9 def test_list_empty(self):10 response = self.client.get(self.url)11 data = {'servers': {'server': []}}12 self.assertEqual(data, response.data)13 def test_list(self):14 servers = {str(o.uuid): o for o in factories.ServerFactory.create_batch(3)}15 response = self.client.get(self.url)16 self.assertIn('servers', response.data)17 self.assertIn('server', response.data['servers'])18 for server_data in response.data['servers']['server']:19 server = servers[server_data['uuid']]20 expected = {21 'uuid': str(server.uuid),22 'firewall': fields.OnOffField().to_representation(server.firewall),23 'timezone': server.timezone,24 'password_delivery': 'none',25 'title': server.title,26 'hostname': server.hostname,27 'licence': 0,28 'core_number': server.core_number,29 'memory_amount': server.memory_amount,30 'state': server.state,31 'boot_order': 'cdrom,disk',32 'host': 4281901271,33 'nic_model': 'e1000',34 'plan': server.plan.name,35 'zone': server.zone.id,36 }37 def test_list_level_0(self):38 account = factories.AccountFactory()39 servers = {str(o.uuid): o for o in factories.ServerFactory.create_batch(3, account=account)}40 servers.update({str(o.uuid): o for o in factories.ServerFactory.create_batch(3)})41 response = self.client.get(self.url)42 self.assertEqual(len(response.data['servers']['server']), 6)43 @patch('ao.upcloud.views.ServerViewSet.access_level', 1)44 def test_list_level_1(self):45 account = factories.AccountFactory()46 servers = {str(o.uuid): o for o in factories.ServerFactory.create_batch(3, account=account)}47 servers.update({str(o.uuid): o for o in factories.ServerFactory.create_batch(3)})48 response = self.client.get(self.url, HTTP_AUTHORIZATION='Basic ' + account.api_key.decode())49 self.assertEqual(len(response.data['servers']['server']), 3)50class ListFirewallRuleTest(APITestCase):51 def test_list_empty(self):52 url = reverse('upcloud:server-firewall-rule', args=[str(uuid.uuid4())])53 response = self.client.get(url)54 data = {'firewall_rules': {'firewall_rule': []}}55 self.assertEqual(data, response.json())56 def test_list_empty(self):57 server = factories.ServerFactory()58 fw_rules = factories.FirewallRuleFactory.create_batch(3, server=server)59 url = reverse('upcloud:server-firewall-rule', args=[str(server.uuid)])60 response = self.client.get(url)61 print(response.json())62 data = {'firewall_rules': {'firewall_rule': []}}63 self.assertEqual(data, response.json())64class GetFirewallRuleTest(APITestCase):65 def test_get_empty(self):66 url = reverse('upcloud:server-firewall-rule-detail', args=[str(uuid.uuid4()), 1])67 response = self.client.get(url)68 data = {'firewall_rule': {}}...
test_field_list.py
Source: test_field_list.py
1# -*- coding: utf-8 -*-2from nose.tools import raises3from obscheme.fields.list import ListField, ListFieldInvalidError4from obscheme.fields.string import StringField5TEST_LIST_EMPTY = []6TEST_LIST_STRINGS = ['foo', 'bar', 'foobar']7TEST_LIST_MIXED = ['foo', 456, 'foobar']8FIELD_NAME = 'test_value'9#----------------------------------------------------------------------10def test_list_validation_success_empty():11 field = ListField(StringField())12 field.validate(FIELD_NAME, TEST_LIST_EMPTY)13#----------------------------------------------------------------------14def test_list_validation_success():15 field = ListField(StringField())16 field.validate(FIELD_NAME, TEST_LIST_STRINGS)17#----------------------------------------------------------------------18@raises(ListFieldInvalidError)19def test_list_validation_error_type():20 field = ListField(StringField())21 field.validate(FIELD_NAME, TEST_LIST_MIXED)22#----------------------------------------------------------------------23def test_list_validation_index_on_exception():24 field = ListField(StringField())25 try:26 field.validate(FIELD_NAME, TEST_LIST_MIXED)27 except ListFieldInvalidError as e:...
test.py
Source: test.py
...3class MyTestCase(unittest.TestCase):4 # Test join function5 def test_concat(self):6 self.assertEqual("Hello World", exercice_1.join(["Hello", "World"], " "))7 def test_list_empty(self):8 self.assertEqual("", exercice_1.join([], " "))9 def test_not_list(self):10 with self.assertRaises(TypeError):11 exercice_1.join(0, "")12 # Test avg function13 def test_avg(self):14 self.assertEqual(2, exercice_1.avg([1, 2, 3]))15 def test_avg_empty(self):16 with self.assertRaises(ZeroDivisionError):17 exercice_1.avg([])18 exercice_1.avg("")19 def test_avg_typeerror(self):20 with self.assertRaises(TypeError):21 exercice_1.avg(1)...
Check out the latest blogs from LambdaTest on this topic:
The fact is not alien to us anymore that cross browser testing is imperative to enhance your application’s user experience. Enhanced knowledge of popular and highly acclaimed testing frameworks goes a long way in developing a new app. It holds more significance if you are a full-stack developer or expert programmer.
QA testers have a unique role and responsibility to serve the customer. Serving the customer in software testing means protecting customers from application defects, failures, and perceived failures from missing or misunderstood requirements. Testing for known requirements based on documentation or discussion is the core of the testing profession. One unique way QA testers can both differentiate themselves and be innovative occurs when senseshaping is used to improve the application user experience.
Having a good web design can empower business and make your brand stand out. According to a survey by Top Design Firms, 50% of users believe that website design is crucial to an organization’s overall brand. Therefore, businesses should prioritize website design to meet customer expectations and build their brand identity. Your website is the face of your business, so it’s important that it’s updated regularly as per the current web design trends.
Enterprise resource planning (ERP) is a form of business process management software—typically a suite of integrated applications—that assists a company in managing its operations, interpreting data, and automating various back-office processes. The introduction of a new ERP system is analogous to the introduction of a new product into the market. If the product is not handled appropriately, it will fail, resulting in significant losses for the business. Most significantly, the employees’ time, effort, and morale would suffer as a result of the procedure.
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!!