コード例 #1
0
ファイル: verifier_tests.py プロジェクト: pombredanne/shtub
    def test_should_render_execution_chain(self, mock_deserialize, mock_exists):
        mock_exists.return_value = True
        execution1 = Execution(
            'command', ['-arg1', '-arg2'], 'stdin', expected=True)
        execution2 = Execution(
            'command', ['-arg1', '-arg3'], 'stdin', expected=True)
        execution3 = Execution(
            'command', ['-arg2', '-arg4'], 'stdin', expected=True)
        execution4 = Execution(
            'command', ['-arg3', '-arg4'], 'stdin', expected=True)
        mock_deserialize.return_value = [
            execution1, execution2, execution3, execution4]

        verifier = VerifierLoader('/hello/world')

        verify = verifier.__enter__()

        execution_chain_stream = StringIO()

        verify.render_execution_chain(execution_chain_stream)

        self.assertEquals(execution_chain_stream.getvalue(),
                          '''     Execution chain
1 | command -arg1 -arg2
2 | command -arg1 -arg3
3 | command -arg2 -arg4
4 | command -arg3 -arg4
''')

        execution_chain_stream.close()
コード例 #2
0
ファイル: verifier_tests.py プロジェクト: pombredanne/shtub
    def test_should_return_empty_verifier_when_filtering_by_argument_not_matching_execution(self, mock_deserialize, mock_exists):
        mock_exists.return_value = True
        execution1 = Execution(
            'command', ['-arg1', '-arg2'], 'stdin', expected=True)
        mock_deserialize.return_value = [execution1]

        verifier = VerifierLoader('/hello/world')

        verify = verifier.__enter__()

        with verify.filter_by_argument('foobar') as verify_foobar:
            self.assertEqual([], verify_foobar.executions)
            verify_foobar.finished()
コード例 #3
0
ファイル: verifier_tests.py プロジェクト: pombredanne/shtub
    def test_should_raise_exception_when_recorded_calls_file_does_not_exist(self, mock_exists):
        mock_exists.return_value = False
        verifier = VerifierLoader('/spam/eggs')

        self.assertRaises(VerificationException, verifier.__enter__)
        self.assertEqual(
            call('/spam/eggs/shtub/executions'), mock_exists.call_args)
コード例 #4
0
ファイル: verifier_tests.py プロジェクト: pombredanne/shtub
    def test_should_raise_exception_when_execution_has_not_been_accepted(self, mock_deserialize, mock_exists):
        mock_exists.return_value = True
        verifier = VerifierLoader('/hello/world')
        execution1 = Execution(
            'any_command1', ['1any_arg1', '1any_arg2'], 'any_stdin1')
        mock_deserialize.return_value = [execution1]

        self.assertRaises(VerificationException, verifier.__enter__)
コード例 #5
0
ファイル: verifier_tests.py プロジェクト: pombredanne/shtub
    def test_should_return_new_verifier_object(self, mock_deserialize, mock_exists):
        mock_exists.return_value = True
        mock_deserialize.return_value = []

        verifier = VerifierLoader('/hello/world')

        with verifier as verify:
            self.assertTrue(verify.filter_by_argument(
                'foobar') is not verify, "should not return itself")
コード例 #6
0
ファイル: verifier_tests.py プロジェクト: pombredanne/shtub
    def test_should_deserialize_recorded_calls_and_return_verifier_itself_when_entering_with_statement(self, mock_deserialize, mock_exists):
        mock_exists.return_value = True
        verifier = VerifierLoader('/hello/world')

        with verifier as veri:
            self.assertEqual(veri, verifier)

        self.assertEqual(
            call('/hello/world/shtub/executions'), mock_deserialize.call_args)
コード例 #7
0
ファイル: verifier_tests.py プロジェクト: pombredanne/shtub
    def test_should_return_empty_verifier_when_filtering_by_argument_without_executions(self, mock_deserialize, mock_exists):
        mock_exists.return_value = True
        mock_deserialize.return_value = []

        verifier = VerifierLoader('/hello/world')

        with verifier as verify:
            with verify.filter_by_argument('foobar') as verify_foobar:

                self.assertEqual([], verify_foobar.executions)
コード例 #8
0
ファイル: verifier_tests.py プロジェクト: pombredanne/shtub
    def test_should_verify_command_has_been_called(self, mock_deserialize, mock_exists):
        mock_exists.return_value = True
        verifier = VerifierLoader('/hello/world')

        stub_execution = Execution(
            'command', ['-arg1', '-arg2'], 'stdin', expected=True)

        mock_deserialize.return_value = [stub_execution]

        with verifier as verify:
            verify.called('command')
            self.assertEqual(0, len(verify.executions))

        self.assertEqual(
            call('/hello/world/shtub/executions'), mock_deserialize.call_args)
コード例 #9
0
ファイル: testbase.py プロジェクト: pombredanne/shtub
 def verify(self):
     return VerifierLoader(self.base_dir)
コード例 #10
0
ファイル: verifier_tests.py プロジェクト: pombredanne/shtub
    def test_should_initialize_recoreded_calls(self):
        verifier = VerifierLoader('/abc/def')

        actual_executions = verifier.executions

        self.assertEqual([], actual_executions)
コード例 #11
0
ファイル: verifier_tests.py プロジェクト: pombredanne/shtub
    def test_should_create_object_with_given_base_dir(self):
        actual = VerifierLoader('/abc/def')

        self.assertEqual('/abc/def', actual.base_dir)