Best Python code snippet using molecule_python
models.py
Source:models.py
...13 def setUp(self):14 self.init_name = "test"15 self.init_use_resource = 516 self.app = oldmodels.Application(name=self.init_name, use_resource=self.init_use_resource)17 def test_name_property(self):18 self.assertEqual(self.app.name, self.init_name)19 def test_name_setter(self):20 set_name = "after"21 self.app.name = set_name22 self.assertEqual(self.app.name, set_name)23 def test_use_resource_property(self):24 self.assertEqual(self.app.use_resource, self.init_use_resource)25 def test_use_resource_setter(self):26 set_use_resource = 1027 self.app.use_resource = set_use_resource28 self.assertEqual(self.app.use_resource, set_use_resource)29 def test_num(self):30 self.assertEqual(oldmodels.Application().name, "a1")31 self.assertEqual(oldmodels.Application().name, "a2")32 self.assertEqual(oldmodels.Application().name, "a3")33class DeviceTestCase(unittest.TestCase):34 def setUp(self):35 self.init_name = "d1"36 self.init_a1_name = "a1"37 self.init_a1_use_resource = 538 self.init_a1 = oldmodels.Application(name=self.init_a1_name, use_resource=self.init_a1_use_resource)39 self.init_apps = [self.init_a1]40 self.device = oldmodels.Device(name=self.init_name, apps=self.init_apps)41 def test_name_property(self):42 self.assertEqual(self.device.name, self.init_name)43 def test_name_setter(self):44 set_name = "d2"45 self.device.name = set_name46 self.assertEqual(self.device.name, set_name)47 def test_use_resource_property(self):48 self.assertEqual(self.device.use_resource, self.init_a1_use_resource)49 def test_apps_property(self):50 self.assertEqual(self.device.apps, self.init_apps)51 def test_append_app(self):52 new_app = oldmodels.Application(name="a2")53 after_apps = self.device.apps54 after_apps.append(new_app)55 self.device.append_app(new_app)56 self.assertEqual(self.device.apps, after_apps)57 def test_remove_app(self):58 remove_app = self.init_a159 self.device.remove_app(remove_app)60 self.assertEqual(self.device.apps, [])61 def test_num(self):62 self.assertEqual(oldmodels.Device().name, "d1")63 self.assertEqual(oldmodels.Device().name, "d2")64 self.assertEqual(oldmodels.Device().name, "d3")65class CloudletTestCase(unittest.TestCase):66 def setUp(self):67 oldmodels.Cloudlet.num = 068 self.init_d1_name = "d1"69 self.init_a1_name = "a1"70 self.init_a1_use_resource = 571 self.init_a1 = oldmodels.Application(name=self.init_a1_name, use_resource=self.init_a1_use_resource)72 self.init_apps = [self.init_a1]73 self.init_d1 = oldmodels.Device(name=self.init_d1_name, apps=self.init_apps)74 self.init_devices = [self.init_d1]75 self.init_max_resource = 1076 self.cloudlet = oldmodels.Cloudlet(r=self.init_max_resource, devices=self.init_devices)77 def test_max_resource_property(self):78 self.assertEqual(self.cloudlet.resource, self.init_max_resource)79 def test_max_resource_setter(self):80 set_max_resource = 881 self.cloudlet.resource = set_max_resource82 self.assertEqual(self.cloudlet.resource, set_max_resource)83 def test_devices_property(self):84 self.assertEqual(self.cloudlet.devices, self.init_devices)85 def test_empty_resource_property(self):86 self.assertEqual(self.cloudlet.empty_resource, self.init_max_resource - self.init_a1_use_resource)87 def test_can_append_device_01(self):88 append_app = oldmodels.Application(name="a2", use_resource=self.init_max_resource - self.init_a1_use_resource)89 a2_apps = [append_app]90 append_device = oldmodels.Device(name="d2", apps=a2_apps)91 self.assertTrue(self.cloudlet.can_append_device(append_device))92 def test_can_append_device_02(self):93 append_app = oldmodels.Application(name="a2", use_resource=self.init_max_resource - self.init_a1_use_resource + 1)94 a2_apps = [append_app]95 append_device = oldmodels.Device(name="d2", apps=a2_apps)96 self.assertFalse(self.cloudlet.can_append_device(append_device))97 def test_append_device_01(self):98 append_app = oldmodels.Application(name="a2", use_resource=self.init_max_resource - self.init_a1_use_resource)99 a2_apps = [append_app]100 append_device = oldmodels.Device(name="d2", apps=a2_apps)101 self.cloudlet.append_device(append_device)102 self.init_devices.append(append_device)103 self.assertEqual(self.cloudlet.devices, self.init_devices)104 def test_append_device_02(self):105 append_app = oldmodels.Application(name="a2", use_resource=self.init_max_resource - self.init_a1_use_resource)106 a2_apps = [append_app]107 append_device = oldmodels.Device(name="d2", apps=a2_apps)108 self.cloudlet.append_device(self.init_d1)109 self.assertRaises(Exception, lambda: self.cloudlet.append_device(append_device))110 def test_name_property(self):111 self.assertEqual(self.cloudlet.name, "c1")112 def test_num(self):113 oldmodels.Cloudlet.num = 0114 self.assertEqual(oldmodels.Cloudlet(r=1).name, "c1")115 self.assertEqual(oldmodels.Cloudlet(r=1).name, "c2")...
test_models.py
Source:test_models.py
...7 super().setUp()8 self.user: User = UserFactory.create(9 first_name="Juha", last_name="Kalulu"10 )11 def test_name_property(self) -> None:12 """Test the `self.name` property."""13 assert self.user.name == "Juha Kalulu"14 def test_representation(self) -> None:15 """Test the `self.__str()__` method."""...
test_name.py
Source:test_name.py
1import pytest2@pytest.mark.asyncio3async def test_name_property(resource):4 """5 In this test check corrected generate name of resource. This name will use6 for admin interface so it's so important.7 """...
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!!