From 97c49406baf621546dc3da6b8e8e3607e0dbeec7 Mon Sep 17 00:00:00 2001 From: Benjamin Bertrand <benjamin.bertrand@esss.se> Date: Fri, 6 Apr 2018 21:58:39 +0200 Subject: [PATCH] Add machine_type field to interfaces API endpoint JIRA INFRA-277 --- app/models.py | 4 ++++ tests/functional/test_api.py | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/app/models.py b/app/models.py index 2dce67c..2e52834 100644 --- a/app/models.py +++ b/app/models.py @@ -645,6 +645,10 @@ class Interface(CreatedMixin, db.Model): 'domain': str(self.network.domain), 'tags': [str(tag) for tag in self.tags], }) + if self.host: + d['machine_type'] = str(self.host.machine_type) + else: + d['machine_type'] = None return d diff --git a/tests/functional/test_api.py b/tests/functional/test_api.py index 50646c9..6ee8513 100644 --- a/tests/functional/test_api.py +++ b/tests/functional/test_api.py @@ -642,7 +642,7 @@ def test_create_interface(client, network_factory, user_token): response = post(client, f'{API_URL}/network/interfaces', data=data, token=user_token) assert response.status_code == 201 assert {'id', 'network', 'ip', 'name', 'mac', 'domain', - 'host', 'cnames', 'tags', 'created_at', + 'host', 'machine_type', 'cnames', 'tags', 'created_at', 'updated_at', 'user'} == set(response.json.keys()) assert response.json['network'] == network.vlan_name assert response.json['ip'] == '192.168.1.20' -- GitLab