Example #1
0
    def test_find_found(self, fetch_device_and_config, to_model):
        device, config = fetch_device_and_config.return_value = (Mock(), Mock())
        model = to_model.return_value = Mock(Device)

        result = device_dao.find(self.deviceid)

        assert_that(result, same_instance(model))
        fetch_device_and_config.assert_called_once_with(self.deviceid)
        to_model.assert_called_once_with(device, config)
Example #2
0
    def test_find_not_found(self, fetch_device_and_config, to_model):
        fetch_device_and_config.return_value = None, None
        to_model.return_value = Mock(Device)

        result = device_dao.find(self.deviceid)

        fetch_device_and_config.assert_called_once_with(self.deviceid)
        assert_that(to_model.call_count, equal_to(0))
        assert_that(result, none())
Example #3
0
    def test_find_not_found(self, fetch_device_and_config, to_model):
        fetch_device_and_config.return_value = None, None
        to_model.return_value = Mock(Device)

        result = device_dao.find(self.deviceid)

        fetch_device_and_config.assert_called_once_with(self.deviceid)
        assert_that(to_model.call_count, equal_to(0))
        assert_that(result, none())
Example #4
0
    def test_find_found(self, fetch_device_and_config, to_model):
        device, config = fetch_device_and_config.return_value = (Mock(),
                                                                 Mock())
        model = to_model.return_value = Mock(Device)

        result = device_dao.find(self.deviceid)

        assert_that(result, same_instance(model))
        fetch_device_and_config.assert_called_once_with(self.deviceid)
        to_model.assert_called_once_with(device, config)
Example #5
0
def _delete_line_from_device(line):
    if hasattr(line, 'device_id') and line.device_id:
        device = device_dao.find(line.device_id)
        if device:
            device_services.remove_line_from_device(device, line)
Example #6
0
def _update_device(line):
    if hasattr(line, 'device_id') and line.device_id:
        device = device_dao.find(line.device_id)
        if device:
            device_services.rebuild_device_config(device)
Example #7
0
def _delete_line_from_device(line):
    if hasattr(line, 'device_id') and line.device_id:
        device = device_dao.find(line.device_id)
        if device:
            device_services.remove_line_from_device(device, line)
Example #8
0
def _update_device(line):
    if hasattr(line, 'device_id') and line.device_id:
        device = device_dao.find(line.device_id)
        if device:
            device_services.rebuild_device_config(device)