예제 #1
0
    def test_edit_only_device(self, provd_build_edit):
        device_id = 'abc1234'
        device = Device(id=device_id)

        provd_device = {'id': device_id}
        provd_config = None

        provd_build_edit.return_value = (provd_device, provd_config)

        with self.provd_managers() as (device_manager, config_manager, _):
            device_manager.get.return_value = provd_device

            device_dao.edit(device)

            device_manager.get.assert_called_once_with(device_id)
            provd_build_edit.assert_called_once_with(device, provd_device, provd_config)
            device_manager.update.assert_called_once_with(provd_device)

            assert_that(config_manager.get.call_count, equal_to(0))
            assert_that(config_manager.update.call_count, equal_to(0))
예제 #2
0
    def test_edit_only_device(self, provd_build_edit):
        device_id = 'abc1234'
        device = Device(id=device_id)

        provd_device = {'id': device_id}
        provd_config = None

        provd_build_edit.return_value = (provd_device, provd_config)

        with self.provd_managers() as (device_manager, config_manager, _):
            device_manager.get.return_value = provd_device

            device_dao.edit(device)

            device_manager.get.assert_called_once_with(device_id)
            provd_build_edit.assert_called_once_with(device, provd_device,
                                                     provd_config)
            device_manager.update.assert_called_once_with(provd_device)

            assert_that(config_manager.get.call_count, equal_to(0))
            assert_that(config_manager.update.call_count, equal_to(0))
예제 #3
0
    def test_edit(self, provd_build_edit):
        device_id = 'abc1234'
        config_id = 'def5678'
        device = Device(id=device_id)

        provd_device = {'id': device_id, 'config': config_id}
        provd_config = Mock()

        provd_build_edit.return_value = (provd_device, provd_config)

        with self.provd_managers() as (device_manager, config_manager, _):
            device_manager.get.return_value = provd_device
            config_manager.get.return_value = provd_config

            device_dao.edit(device)

            device_manager.get.assert_called_once_with(device_id)
            config_manager.get.assert_called_once_with(config_id)
            provd_build_edit.assert_called_once_with(device, provd_device, provd_config)
            device_manager.update.assert_called_once_with(provd_device)
            config_manager.update.assert_called_once_with(provd_config)
예제 #4
0
    def test_edit(self, provd_build_edit):
        device_id = 'abc1234'
        config_id = 'def5678'
        device = Device(id=device_id)

        provd_device = {'id': device_id, 'config': config_id}
        provd_config = Mock()

        provd_build_edit.return_value = (provd_device, provd_config)

        with self.provd_managers() as (device_manager, config_manager, _):
            device_manager.get.return_value = provd_device
            config_manager.get.return_value = provd_config

            device_dao.edit(device)

            device_manager.get.assert_called_once_with(device_id)
            config_manager.get.assert_called_once_with(config_id)
            provd_build_edit.assert_called_once_with(device, provd_device,
                                                     provd_config)
            device_manager.update.assert_called_once_with(provd_device)
            config_manager.update.assert_called_once_with(provd_config)