diff --git a/app/models.py b/app/models.py index f01bbe72ace9a7d8630df66dc23a18b9573cb395..0afa49f508fd1fd8f11cdc2eabd54eae0d29b569 100644 --- a/app/models.py +++ b/app/models.py @@ -958,8 +958,10 @@ class Interface(CreatedMixin, db.Model): ) if self.host: d["device_type"] = str(self.host.device_type) + d["model"] = utils.format_field(self.host.model) else: d["device_type"] = None + d["model"] = None return d diff --git a/tests/functional/test_api.py b/tests/functional/test_api.py index f6b5ede4a20b5424b74c169a3e956a3c72dc711e..681af8d9e180f224a086e98676696f861f9d46ef 100644 --- a/tests/functional/test_api.py +++ b/tests/functional/test_api.py @@ -914,6 +914,17 @@ def test_get_interfaces_by_domain( check_input_is_subset_of_response(response, (interface3.to_dict(),)) +def test_get_interfaces_with_model( + client, model_factory, item_factory, host_factory, interface_factory, readonly_token +): + host1 = host_factory() + model1 = model_factory(name="EX3400") + item_factory(model=model1, host_id=host1.id) + interface_factory(host_id=host1.id) + response = get(client, f"{API_URL}/network/interfaces", token=readonly_token) + assert response.json[0]["model"] == "EX3400" + + def test_create_interface(client, network_factory, user_token): network = network_factory( address="192.168.1.0/24", first_ip="192.168.1.10", last_ip="192.168.1.250" @@ -950,6 +961,7 @@ def test_create_interface(client, network_factory, user_token): "domain", "host", "device_type", + "model", "cnames", "tags", "created_at",