Passed
Push — master ( 45645d...9c7185 )
by Humberto
01:09 queued 11s
created

build.models.Host.as_dict()   A

Complexity

Conditions 1

Size

Total Lines 4
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 1
CRAP Score 1.125

Importance

Changes 0
Metric Value
eloc 3
dl 0
loc 4
ccs 1
cts 2
cp 0.5
rs 10
c 0
b 0
f 0
cc 1
nop 1
crap 1.125
1
"""Most relevant classes to be used on the topology."""
2
3
4 1
__all__ = ('Host', 'Topology')
5
6
7 1
class Topology:
8
    """Represent the topology with links and switches."""
9
10 1
    def __init__(self, switches, links):
11
        """Create a instance of Topology."""
12
        self.switches = switches
13
        self.links = links
14
15
16 1
class Host:
17
    """Represents the Host."""
18
19 1
    def __init__(self, mac):
20
        """Create a instance of Host."""
21
        self.mac = mac
22
23 1
    @property
24
    def id(self):  # pylint: disable=invalid-name
25
        """Return the host id."""
26
        return self.mac
27
28 1
    def as_dict(self):
29
        """Return a dict representation of a Host."""
30
        return {'mac': self.mac,
31
                'type': 'host'}
32