1
# Copyright 2014 Canonical Ltd. This software is licensed under the
2
# GNU Affero General Public License version 3 (see the file LICENSE).
4
"""Tests for `NodeGroupInterface` part of region service."""
6
from __future__ import (
17
from maasserver.rpc.nodegroupinterface import get_cluster_interfaces_as_dicts
18
from maasserver.testing.factory import factory
19
from maasserver.testing.testcase import MAASServerTestCase
22
class TestGetClusterInterfacesAsDicts(MAASServerTestCase):
24
def test__returns_cluster_interface(self):
25
interface = factory.make_NodeGroupInterface(factory.make_NodeGroup())
29
b'name': interface.name,
30
b'interface': interface.interface,
34
get_cluster_interfaces_as_dicts(interface.nodegroup.uuid))
36
def test__returns_all_interfaces_on_cluster(self):
37
nodegroup = factory.make_NodeGroup()
39
factory.make_NodeGroupInterface(nodegroup)
42
received_interfaces = get_cluster_interfaces_as_dicts(nodegroup.uuid)
43
self.assertItemsEqual(
44
[expected_interface.name for expected_interface in interfaces],
46
received_interface['name']
47
for received_interface in received_interfaces
50
def test__ignores_other_clusters(self):
51
nodegroup = factory.make_NodeGroup()
52
factory.make_NodeGroupInterface(factory.make_NodeGroup())
53
self.assertEqual([], get_cluster_interfaces_as_dicts(nodegroup.uuid))