|
| 1 | +from visualiser import * |
| 2 | + |
| 3 | +""" |
| 4 | + Test case class for nodes |
| 5 | +""" |
| 6 | +class TestNode: |
| 7 | + def test_create_new_node(self): |
| 8 | + node = Node('bishal', 'Bishal label', color='red', style='filled') |
| 9 | + |
| 10 | + assert node.label == 'Bishal label' |
| 11 | + assert node.name == 'bishal' |
| 12 | + assert node.get_attribute('color') == 'red' |
| 13 | + assert node.get_attribute('style') == 'filled' |
| 14 | + assert node.to_string() == 'bishal [label="Bishal label", color="red", style="filled"];' |
| 15 | + |
| 16 | + def test_set_attributes(self): |
| 17 | + node = Node('bishal', 'Bishal label', color='red', style='filled') |
| 18 | + assert node.get_attribute('color') == 'red' |
| 19 | + node.set_attribute('color', 'green') |
| 20 | + assert node.get_attribute('color') == 'green' |
| 21 | + node.set_attribute('background', 'grey') |
| 22 | + assert node.get_attribute('background') == 'grey' |
| 23 | + assert node.to_string() == 'bishal [label="Bishal label", color="green", style="filled", background="grey"];' |
| 24 | + |
| 25 | + def test_rename_name_label(self): |
| 26 | + node = Node('bishal', 'Bishal label', color='red', style='filled') |
| 27 | + |
| 28 | + node.set_attribute('color', 'green') |
| 29 | + |
| 30 | + assert node.label == 'Bishal label' |
| 31 | + node.label = 'Bishal renamed label' |
| 32 | + assert node.label == 'Bishal renamed label' |
| 33 | + |
| 34 | + assert node.name == 'bishal' |
| 35 | + node.name = 'Bishal renamed' |
| 36 | + assert node.name == 'Bishal renamed' |
| 37 | + |
| 38 | + assert node.to_string() == 'Bishal renamed [label="Bishal renamed label", color="green", style="filled"];' |
| 39 | + |
| 40 | + |
0 commit comments