def test_take_action(self, m_dev_obj):

        # remove ShowOne from the DeviceShow inheritance
        bases = copy(dr.DeviceRemove.__bases__)
        f_bases = tuple(base for base in bases if base != ShowOne)

        m_args = mock.Mock()
        m_args._get_kwargs.return_value = {"id": 1}

        m_mod_dev = mock.Mock()
        m_mod_dev.id = 1
        m_mod_dev.name = 'test'
        m_mod_dev.interface = DeviceInterfaces.SERIAL
        m_mod_dev.implementation = dm.get_device_implementations()[0].NAME
        m_dev_obj.delete.return_value = m_mod_dev

        m_base = mock.patch.object(dr.DeviceRemove, '__bases__', f_bases)
        with m_base:
            m_base.is_local = True
            t_device = dr.DeviceRemove()

            t_device.app = mock.Mock()

            t_result = t_device.take_action(m_args)
            self.assertEqual(t_result[1][0], m_mod_dev.id)
            self.assertEqual(t_result[1][1], m_mod_dev.name)
            self.assertEqual(t_result[1][2], m_mod_dev.interface)
            self.assertEqual(t_result[1][3], m_mod_dev.implementation)

        # ensure that is_local on the patch does not modify the actual bases
        self.assertEqual(bases, dr.DeviceRemove.__bases__)
    def test_arguments(self, m_super):
        m_super.return_value = mock.Mock(
            arguments={
                '--id': Argument(),
                '--interface': Argument(),
                '--implementation': Argument()
            })

        bases = copy(dr.DeviceRemove.__bases__)
        f_bases = tuple(base for base in bases if base != ShowOne)

        m_base = mock.patch.object(dr.DeviceRemove, '__bases__', f_bases)
        with m_base:
            m_base.is_local = True
            t_device = dr.DeviceRemove()
            t_device.register_arguments(mock.Mock())

            m_super.assert_called_once()

            self.assertTrue('--id' in t_device._arguments.keys())
            self.assertFalse('--implementation' in t_device._arguments.keys())
            self.assertFalse('--interface' in t_device._arguments.keys())

        # ensure that is_local on the patch does not modify the actual bases
        self.assertEqual(bases, dr.DeviceRemove.__bases__)
    def test_parser(self, m_super):

        m_parser = mock.Mock()
        m_super.return_value.get_parser.return_value = m_parser

        # remove ShowOne from the DeviceShow inheritance
        bases = copy(dr.DeviceRemove.__bases__)
        f_bases = tuple(base for base in bases if base != ShowOne)

        m_base = mock.patch.object(dr.DeviceRemove, '__bases__', f_bases)
        with m_base:
            m_base.is_local = True
            t_device = dr.DeviceRemove()

            t_device.register_arguments = mock.Mock()

            t_device.get_parser("test")

            t_device.register_arguments.assert_called_once_with(m_parser)

        # ensure that is_local on the patch does not modify the actual bases
        self.assertEqual(bases, dr.DeviceRemove.__bases__)
    def test_take_action_multiple(self, m_dev_obj):

        # remove ShowOne from the DeviceShow inheritance
        bases = copy(dr.DeviceRemove.__bases__)
        f_bases = tuple(base for base in bases if base != ShowOne)

        m_args = mock.Mock()
        m_args._get_kwargs.return_value = {'id': 1}

        m_dev_obj.delete.side_effect = MultipleResultsFound()

        m_base = mock.patch.object(dr.DeviceRemove, '__bases__', f_bases)
        with m_base:
            m_base.is_local = True
            t_device = dr.DeviceRemove()

            t_device.app = mock.Mock()

            self.assertRaises(RuntimeWarning, t_device.take_action, m_args)

        # ensure that is_local on the patch does not modify the actual bases
        self.assertEqual(bases, dr.DeviceRemove.__bases__)