Пример #1
0
    def test_setups(self):
        builder = DeviceBuilder(self.module)

        setups = builder.setups
        self.assertEqual(len(setups), 2)
        self.assertIn('default', setups)
        self.assertIn('other', setups)
Пример #2
0
    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')
Пример #3
0
    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)
Пример #4
0
    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')
Пример #5
0
    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)
Пример #6
0
    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)
Пример #7
0
    def test_init(self):
        assertRaisesNothing(self, DeviceBuilder, self.module)

        builder = DeviceBuilder(self.module)
        self.assertEqual(builder.name, self.module.__name__)
Пример #8
0
    def test_defaults(self):
        builder = DeviceBuilder(self.module)

        self.assertIs(builder.default_device_type, None)
        self.assertIs(builder.default_protocol, None)
Пример #9
0
    def test_create_device(self):
        builder = DeviceBuilder(self.module)

        self.assertRaises(LewisException, builder.create_device)
        self.assertRaises(LewisException, builder.create_device, 'default')
Пример #10
0
    def test_protocols(self):
        builder = DeviceBuilder(self.module)

        protocols = builder.protocols
        self.assertEqual(len(protocols), 1)
        self.assertIn("dummy", protocols)
Пример #11
0
    def test_setups(self):
        builder = DeviceBuilder(self.module)

        setups = builder.setups
        self.assertEqual(len(setups), 1)
        self.assertIn("default", setups)