-
Notifications
You must be signed in to change notification settings - Fork 0
/
topology_tests.py
26 lines (20 loc) · 993 Bytes
/
topology_tests.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import unittest
from topology import ChainTopo, InvalidNumberOfSwitches
class TestAlbum(unittest.TestCase):
def test_WhenGivenThreeSwitchesItShouldReturnATopologyWithThreeSwitches(self):
topology = ChainTopo(number_of_switches = 3)
assert len(topology.switches()) == 3
assert len(topology.hosts()) == 4
def test_WhenGivenTenSwitchesItShouldReturnATopologyWithTenSwitches(self):
topology = ChainTopo(number_of_switches = 10)
assert len(topology.switches()) == 10
assert len(topology.hosts()) == 4
def test_WhenGivenZeroSwitchesItShouldRaiseAnException(self):
with self.assertRaises(InvalidNumberOfSwitches):
ChainTopo(number_of_switches = 0)
def test_WhenGivenTwoSwitchesItShouldReturnATopologyWithTwoSwitches(self):
topology = ChainTopo(number_of_switches = 2)
assert len(topology.switches()) == 2
assert len(topology.hosts()) == 4
if __name__ == '__main__':
unittest.main()