<commit_before>import unittest
import mock

from gant.ant_workflow import *

class TestWorkflow(unittest.TestCase):

    def test_enter_transitions_multiple_states(self):
        s1 = mock.Mock()
        s2 = mock.Mock()
        s3 = mock.Mock()
        s1.enter.return_value = s2
        s2.enter.return_value = s3
        s3.enter.return_value = None
        wf = Workflow(s1)
        self.assertEquals(wf.enter(None, None), None)
        self.assertEquals(wf.state, s3)
        s1.enter.assert_called_with(None, None)
        s2.enter.assert_called_with(None, s1)
        s3.enter.assert_called_with(None, s2)
        
    def test_final_state(self):
        s1 = mock.Mock()
        s1.accept.return_value = FINAL_STATE
        s2 = mock.Mock()
        wf = Workflow(s1)
        wf.next_state = s2
        self.assertEquals(wf.accept(None, None), s2)

    def test_state_requests_reentry(self):
        s1 = mock.Mock()
        s1.accept.return_value = s1
        s1.enter.return_value = None
        wf = Workflow(s1)
        self.assertEquals(wf.accept(None, None), None)
        self.assertEquals(wf.state, s1)
        s1.accept.assert_called_with(None, None)
        s1.enter.assert_called_with(None, s1)


# vim: et ts=4 sts=4
<commit_msg>unit test<commit_after>import unittest
import mock

from gant.ant_workflow import *

class TestWorkflow(unittest.TestCase):

    def test_enter_transitions_multiple_states(self):
        s1 = mock.Mock()
        s2 = mock.Mock()
        s3 = mock.Mock()
        s1.enter.return_value = s2
        s2.enter.return_value = s3
        s3.enter.return_value = None
        wf = Workflow(s1)
        self.assertEquals(wf.enter(None, None), None)
        self.assertEquals(wf.state, s3)
        s1.enter.assert_called_with(None, None)
        s2.enter.assert_called_with(None, s1)
        s3.enter.assert_called_with(None, s2)
        
    def test_final_state(self):
        s1 = mock.Mock()
        s1.accept.return_value = FINAL_STATE
        s2 = mock.Mock()
        wf = Workflow(s1)
        wf.next_state = s2
        self.assertEquals(wf.accept(None, None), s2)

    def test_state_requests_reentry(self):
        s1 = mock.Mock()
        s1.accept.return_value = s1
        s1.enter.return_value = None
        wf = Workflow(s1)
        self.assertEquals(wf.accept(None, None), None)
        self.assertEquals(wf.state, s1)
        s1.accept.assert_called_with(None, None)
        s1.enter.assert_called_with(None, s1)

    def test_workflow_is_state(self):
        state = mock.Mock()
        state.enter.return_value = None
        state.accept.return_value = state
        w1 = Workflow(state)
        w2 = Workflow(w1)
        w3 = Workflow(w2)
        self.assertEquals(w3.enter(None, None), None)
        state.enter.assert_called_with(None, None)
        self.assertEquals(w3.accept(None, None), None)
        state.accept.assert_called_with(None, None)
        state.enter.assert_called_with(None, state)
        state.accept.return_value = ERROR_STATE
        self.assertEquals(w3.accept(None, None), ERROR_STATE)


# vim: et ts=4 sts=4

{'fraction_non_alphanumeric': 0.10723514211886305, 'fraction_numerical': 0.023255813953488372, 'mean_word_length': 2.4258849557522124, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7359686', 'n_tokens_mistral': 1081, 'n_tokens_neox': 1053, 'n_words': 180}