37
37
self.assertRaises(OverlappingActionError, timeline.start,
38
38
"Sending mail", "Noone")
40
def test_nested_start_permitted(self):
41
# When explicitly requested a nested start can be done
43
action = timeline.start("Calling openid", "hostname", allow_nested=True)
44
child = timeline.start("SQL Callback", "SELECT...")
46
def test_nested_start_is_not_transitive(self):
47
# nesting is explicit at each level - not inherited.
49
action = timeline.start("Calling openid", "hostname", allow_nested=True)
50
child = timeline.start("SQL Callback", "SELECT...")
51
self.assertRaises(OverlappingActionError, timeline.start,
52
"Sending mail", "Noone")
54
def test_multiple_nested_children_permitted(self):
55
# nesting is not reset by each action that is added.
57
action = timeline.start("Calling openid", "hostname", allow_nested=True)
58
child = timeline.start("SQL Callback", "SELECT...")
60
child = timeline.start("SQL Callback", "SELECT...")
62
def test_multiple_starts_after_nested_group_prevented(self):
63
# nesting stops being permitted when the nesting action is finished.
65
action = timeline.start("Calling openid", "hostname", allow_nested=True)
67
child = timeline.start("SQL Callback", "SELECT...")
68
self.assertRaises(OverlappingActionError, timeline.start,
69
"Sending mail", "Noone")
71
def test_nesting_within_nesting_permitted(self):
73
action = timeline.start("Calling openid", "hostname", allow_nested=True)
74
middle = timeline.start("Calling otherlibrary", "", allow_nested=True)
75
child = timeline.start("SQL Callback", "SELECT...")
77
def test_finishing_nested_within_nested_leaves_outer_nested_nesting(self):
79
action = timeline.start("Calling openid", "hostname", allow_nested=True)
80
middle = timeline.start("Calling otherlibrary", "", allow_nested=True)
82
child = timeline.start("SQL Callback", "SELECT...")
84
def test_nested_actions_recorded_as_two_zero_length_actions(self):
86
action = timeline.start("Calling openid", "hostname", allow_nested=True)
87
child = timeline.start("SQL Callback", "SELECT...")
90
self.assertEqual(3, len(timeline.actions))
91
self.assertEqual(datetime.timedelta(), timeline.actions[0].duration)
92
self.assertEqual(datetime.timedelta(), timeline.actions[2].duration)
94
def test_nested_category_labels(self):
95
# To identify start/stop pairs '-start' and '-stop' are put onto the
96
# category of nested actions:
98
action = timeline.start("Calling openid", "hostname", allow_nested=True)
100
self.assertEqual('Calling openid-start', timeline.actions[0].category)
101
self.assertEqual('Calling openid-stop', timeline.actions[1].category)
40
103
def test_start_after_finish_works(self):
41
104
timeline = Timeline()
42
105
action = timeline.start("Sending mail", "Noone")