Ejemplo n.º 1
0
    def test_build_edit_with_new_properties_and_no_config(self):
        device_id = 'abc123'

        device = Device(
            id=device_id,
            ip='10.0.0.1',
            mac='00:11:22:33:44:55',
            plugin='aastraplugin',
            model='6735i',
            vendor='Aastra',
            version='0.0.1'
        )

        provd_device = {
            'configured': False,
            'id': device_id
        }

        expected_provd_device = {
            'configured': False,
            'id': device_id,
            'ip': '10.0.0.1',
            'mac': '00:11:22:33:44:55',
            'plugin': 'aastraplugin',
            'model': '6735i',
            'vendor': 'Aastra',
            'version': '0.0.1'
        }

        result_device, result_config = provd_converter.build_edit(device, provd_device, None)

        assert_that(result_device, equal_to(expected_provd_device))
Ejemplo n.º 2
0
    def test_build_edit_with_new_properties_and_no_config(self):
        device_id = 'abc123'

        device = Device(id=device_id,
                        ip='10.0.0.1',
                        mac='00:11:22:33:44:55',
                        plugin='aastraplugin',
                        model='6735i',
                        vendor='Aastra',
                        version='0.0.1')

        provd_device = {'configured': False, 'id': device_id}

        expected_provd_device = {
            'configured': False,
            'id': device_id,
            'ip': '10.0.0.1',
            'mac': '00:11:22:33:44:55',
            'plugin': 'aastraplugin',
            'model': '6735i',
            'vendor': 'Aastra',
            'version': '0.0.1'
        }

        result_device, result_config = provd_converter.build_edit(
            device, provd_device, None)

        assert_that(result_device, equal_to(expected_provd_device))
Ejemplo n.º 3
0
def edit(device):
    provd_device = _find_device_from_provd(device.id)
    provd_config = _find_config_from_device(provd_device)

    provd_device, provd_config = provd_converter.build_edit(device, provd_device, provd_config)

    if provd_config:
        _update_provd_config(provd_config)

    _update_provd_device(provd_device)
Ejemplo n.º 4
0
def edit(device):
    provd_device = _find_device_from_provd(device.id)
    provd_config = _find_config_from_device(provd_device)

    provd_device, provd_config = provd_converter.build_edit(
        device, provd_device, provd_config)

    if provd_config:
        _update_provd_config(provd_config)

    _update_provd_device(provd_device)
Ejemplo n.º 5
0
    def test_build_edit_with_an_empty_device_and_no_config(self):
        device_id = 'abc123'
        device = Device(id=device_id)

        provd_device = {
            'configured': False,
            'id': device_id,
        }

        expected_provd_device = {
            'configured': False,
            'id': device_id,
        }

        result_device, result_config = provd_converter.build_edit(device, provd_device, None)

        assert_that(result_device, equal_to(expected_provd_device))
Ejemplo n.º 6
0
    def test_build_edit_with_an_empty_device_and_no_config(self):
        device_id = 'abc123'
        device = Device(id=device_id)

        provd_device = {
            'configured': False,
            'id': device_id,
        }

        expected_provd_device = {
            'configured': False,
            'id': device_id,
        }

        result_device, result_config = provd_converter.build_edit(
            device, provd_device, None)

        assert_that(result_device, equal_to(expected_provd_device))
Ejemplo n.º 7
0
    def test_build_edit_with_a_template_id_and_a_custom_config(self):
        device_id = 'def456'
        config_id = 'abc123'

        device = Device(
            id=device_id,
            template_id='mytemplate'
        )

        provd_device = {
            'configured': True,
            'id': device_id,
            'config': config_id
        }

        provd_config = {
            'configdevice': 'defaultconfigdevice',
            'deletable': True,
            'id': config_id,
            'parent_ids': ['base', 'defaultconfigdevice'],
            'raw_config': {
            }
        }

        expected_provd_device = {
            'configured': True,
            'id': device_id,
            'config': config_id
        }

        expected_provd_config = {
            'configdevice': 'mytemplate',
            'deletable': True,
            'id': config_id,
            'parent_ids': ['base', 'mytemplate'],
            'raw_config': {
            }
        }

        result_device, result_config = provd_converter.build_edit(device, provd_device, provd_config)

        assert_that(result_device, equal_to(expected_provd_device))
        assert_that(result_config, equal_to(expected_provd_config))
Ejemplo n.º 8
0
    def test_build_edit_with_a_template_id_and_a_custom_config(self):
        device_id = 'def456'
        config_id = 'abc123'

        device = Device(id=device_id, template_id='mytemplate')

        provd_device = {
            'configured': True,
            'id': device_id,
            'config': config_id
        }

        provd_config = {
            'configdevice': 'defaultconfigdevice',
            'deletable': True,
            'id': config_id,
            'parent_ids': ['base', 'defaultconfigdevice'],
            'raw_config': {}
        }

        expected_provd_device = {
            'configured': True,
            'id': device_id,
            'config': config_id
        }

        expected_provd_config = {
            'configdevice': 'mytemplate',
            'deletable': True,
            'id': config_id,
            'parent_ids': ['base', 'mytemplate'],
            'raw_config': {}
        }

        result_device, result_config = provd_converter.build_edit(
            device, provd_device, provd_config)

        assert_that(result_device, equal_to(expected_provd_device))
        assert_that(result_config, equal_to(expected_provd_config))