def test_create(self, validate_create, device_dao_create, notifier_created): expected_device = { 'ip': '10.9.0.5', 'mac': '00:11:22:33:44:55', 'template_id': 'abcd1234', 'plugin': 'superduperplugin', 'vendor': 'Aastra', 'model': '6531i', } device = Device(**expected_device) device_dao_create.return_value = Device(**expected_device) result = device_services.create(device) validate_create.assert_called_with(device) device_dao_create.assert_called_once_with(device) notifier_created.assert_called_once_with(result) self.assertEquals(result.mac, expected_device['mac']) self.assertEquals(result.ip, expected_device['ip']) self.assertEquals(result.template_id, expected_device['template_id']) self.assertEquals(result.plugin, expected_device['plugin']) self.assertEquals(result.vendor, expected_device['vendor']) self.assertEquals(result.model, expected_device['model'])
def create(): data = document.parse(request) device = formatter.dict_to_model(data) created_device = device_services.create(device) result = formatter.to_api(created_device) location = url_for('.get', deviceid=created_device.id) return make_response(result, 201, {'Location': location})
def test_create_empty_device(self, notifier_created, device_dao_create): device = Device() created_device = Device(id='abcd') device_dao_create.return_value = created_device result = device_services.create(device) self.assertEquals(result.id, created_device.id) device_dao_create.assert_called_once_with(device) notifier_created.assert_called_once_with(result)
def _create_dummy_devices(channel, nb_devices): from xivo_dao.data_handler.device import services as device_services from xivo_dao.data_handler.device.model import Device for i in range(nb_devices): device_services.create(Device())