def test_add_partial_timeline__contradiction(self): """Verify that order contradiction is detected and avoided. """ partial_timelines = [ ['one', 'two', 'three'], ['three', 'two']] timeline = Timeline() timeline.add_partial_timeline(partial_timelines[0]) self.assertRaisesRegexp( ValueError, "Contradiction detected: event 'three' comes before and after event 'two'", timeline.add_partial_timeline, partial_timelines[1])
def test_add_partial_timeline__simple(self): """Verify side-effects of single call to add_partial_timeline. """ partial_timeline = ['one', 'two', 'three', 'four'] timeline = Timeline() timeline.add_partial_timeline(partial_timeline) # Verify internal timeline data expected_subsequent_events = {'one': set(['two']), 'two': set(['three']), 'three': set(['four']), 'four': set()} self.assertEqual(expected_subsequent_events, timeline._subsequent_events)