Exemplo n.º 1
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')
Exemplo n.º 2
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')
Exemplo n.º 3
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)
Exemplo n.º 4
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)
Exemplo n.º 5
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)
Exemplo n.º 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)
Exemplo n.º 7
0
    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)
Exemplo n.º 9
0
    def test_defaults(self):
        builder = DeviceBuilder(self.module)

        self.assertIs(builder.default_device_type, None)
        self.assertIs(builder.default_protocol, None)
Exemplo n.º 10
0
    def test_create_device(self):
        builder = DeviceBuilder(self.module)

        self.assertRaises(LewisException, builder.create_device)
        self.assertRaises(LewisException, builder.create_device, 'default')
Exemplo n.º 11
0
    def test_protocols(self):
        builder = DeviceBuilder(self.module)

        protocols = builder.protocols
        self.assertEqual(len(protocols), 1)
        self.assertIn("dummy", protocols)
Exemplo n.º 12
0
    def test_setups(self):
        builder = DeviceBuilder(self.module)

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