def test__trigger_and_termination_not_matches(self):
     s = SequenceNode(1)
     s.condition_id = 3
     data = {2: True}
     expected = {'result': 0, 'termination': True}
     result = s.process(data)
     self.assertEqual(expected, result)
    def test__two_sequences__first_sequence_changes_state_on_match(self):
        s1 = SequenceNode(1)
        s2 = SequenceNode(2)
        s2.add_prev_sequence(s1)
        s1.condition_id = 1

        data = {1: True}
        expected = {'result': 1, 'termination': False}
        result = s1.process(data)

        self.assertEqual(SequenceState.proxy, s1.state)
        self.assertEqual(expected, result)
class SequenceBasicTests(unittest.TestCase):
    def setUp(self):
        self.s = SequenceNode(1)

    def test__initial_values(self):
        self.assertEqual(Offset, self.s.offset.__class__)
        self.assertEqual(None, self.s.prev_sequence)
        self.assertEqual(None, self.s.next_sequence)
        self.assertEqual(0, self.s.condition_id)
        self.assertEqual(1, self.s.id)
        self.assertEqual(SequenceState.idle, self.s.state)
        self.assertEqual(0, self.s.proxy_counter)

    def test__passing_id_to_constructor(self):
        s = SequenceNode(1)
        self.assertEqual(1, s.id)

    def test__is_trigger_case_1(self):
        self.assertTrue(self.s.is_trigger())

    def test__is_trigger_case_2(self):
        self.s.prev_sequence = 1
        self.assertFalse(self.s.is_trigger())

    def test__is_termination_case_1(self):
        self.assertTrue(self.s.is_termination())

    def test__is_termination_case_2(self):
        self.s.next_sequence = 1
        self.assertFalse(self.s.is_termination())

    def test__adding_parent_sets_reference_in_children_too(self):
        s1 = SequenceNode(1)
        s2 = SequenceNode(2)
        s2.add_prev_sequence(s1)
        self.assertEqual(s1, s2.prev_sequence)
        self.assertEqual(s2, s1.next_sequence)
 def test__two_sequences__first_node_emits_offset_information_in_proxy_mode(self):
     s1 = SequenceNode(1)
     s1.state = SequenceState.proxy
     s1.condition_id = 1
     dummy = SequenceNode(2)
     dummy.add_prev_sequence(s1)
     self.assertEqual(0, s1.proxy_counter)
     s1.process(None)
     self.assertEqual(1, s1.proxy_counter)
     s1.process(None)
     self.assertEqual(2, s1.proxy_counter)
 def setUp(self):
     self.s = SequenceNode(1)
 def test__no_condition_specified__raise_error(self):
     s = SequenceNode(1)
     with self.assertRaises(ValueError):
         s.process(None)
 def test__adding_parent_sets_reference_in_children_too(self):
     s1 = SequenceNode(1)
     s2 = SequenceNode(2)
     s2.add_prev_sequence(s1)
     self.assertEqual(s1, s2.prev_sequence)
     self.assertEqual(s2, s1.next_sequence)
 def test__passing_id_to_constructor(self):
     s = SequenceNode(1)
     self.assertEqual(1, s.id)