Test Failed
Pull Request — master (#96)
by
unknown
01:49
created

build.models.Status.as_dict()   A

Complexity

Conditions 1

Size

Total Lines 4
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 3
nop 1
dl 0
loc 4
rs 10
c 0
b 0
f 0
ccs 0
cts 0
cp 0
crap 2
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 1
        self.switches = switches
13 1
        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
33
34
class Status:
35
    """Represents the administratively the network status."""
36
37
    def __init__(self, status_id, status):
38
        """Create a instance the network status."""
39
        self.status = status
40
        self.status_id = status_id
41
42
    def as_dict(self):
43
        """Return a dict."""
44
        return {'id': self.status_id,
45
                'status': self.status}
46