def test_create_device(self): builder = DeviceBuilder(self.module) device = builder.create_device() self.assertIsInstance(device, self.module.DummyDevice) self.assertRaises(LewisException, builder.create_device, 'invalid_setup')
def test_create_interface(self): builder = DeviceBuilder(self.module) self.assertIsInstance(builder.create_interface(), self.module.DummyAdapter) self.assertIsInstance( builder.create_interface('dummy'), self.module.DummyAdapter) self.assertRaises(LewisException, builder.create_interface, 'invalid_protocol')
def test_create_device(self): builder = DeviceBuilder(self.module) self.assertIsInstance(builder.create_device(), self.module.DummyDevice) self.assertIsInstance(builder.create_device("default"), self.module.DummyDevice) self.assertIsInstance(builder.create_device("other"), self.module.OtherDummyDevice)
def test_setups(self): builder = DeviceBuilder(self.module) setups = builder.setups self.assertEqual(len(setups), 2) self.assertIn('default', setups) self.assertIn('other', setups)
def test_protocols(self): builder = DeviceBuilder(self.module) protocols = builder.protocols self.assertEqual(len(protocols), 2) self.assertIn('dummy', protocols) self.assertIn('other_dummy', protocols)
def test_defaults(self): builder = DeviceBuilder(self.module) self.assertIs(builder.default_device_type, self.module.DummyDevice) self.assertIs(builder.default_protocol, self.module.DummyAdapter.protocol)
def test_init(self): assertRaisesNothing(self, DeviceBuilder, self.module) builder = DeviceBuilder(self.module) self.assertEqual(builder.name, self.module.__name__)
def test_create_device(self): builder = DeviceBuilder(self.module) self.assertIsInstance(builder.create_device(), self.module.DummyDevice) self.assertIsInstance(builder.create_device('default'), self.module.DummyDevice) self.assertIsInstance(builder.create_device('other'), self.module.OtherDummyDevice)
def test_defaults(self): builder = DeviceBuilder(self.module) self.assertIs(builder.default_device_type, None) self.assertIs(builder.default_protocol, None)
def test_create_device(self): builder = DeviceBuilder(self.module) self.assertRaises(LewisException, builder.create_device) self.assertRaises(LewisException, builder.create_device, 'default')
def test_protocols(self): builder = DeviceBuilder(self.module) protocols = builder.protocols self.assertEqual(len(protocols), 1) self.assertIn("dummy", protocols)
def test_setups(self): builder = DeviceBuilder(self.module) setups = builder.setups self.assertEqual(len(setups), 1) self.assertIn("default", setups)