Example #1
0
    def test_should_pop_verified_execution(self):
        stub_execution = Execution(
            'command', ['-arg1', '-arg2'], 'stdin', expected=True)
        verifier = Verifier([stub_execution])

        verifier.called('command')

        self.assertEqual(0, len(verifier.executions))
Example #2
0
    def test_should_raise_exception_when_one_more_recorded_calls_available_than_verified(self):
        execution1 = Execution(
            'command', ['-arg1', '-arg2'], 'stdin', expected=True)
        execution2 = Execution(
            'command', ['-arg1', '-arg2'], 'stdin', expected=True)
        verifier = Verifier([execution1, execution2])

        verifier.called('command')

        self.assertRaises(
            VerificationException, verifier.__exit__, None, None, None)
Example #3
0
    def test_should_return_false_when_an_exception_occured_in_the_with_statement(self):
        execution1 = Execution(
            'command', ['-arg1', '-arg2'], 'stdin', expected=True)
        execution2 = Execution(
            'command', ['-arg1', '-arg2'], 'stdin', expected=True)
        verifier = Verifier([execution1, execution2])

        verifier.called('command')
        actual_result = verifier.__exit__(
            'exception_type', 'exception_value', 'traceback')

        self.assertFalse(actual_result)
Example #4
0
    def test_should_raise_exception_when_expected_command_has_not_been_executed(self):
        stub_execution = Execution(
            'command', ['-arg1', '-arg2'], 'stdin', expected=True)
        verifier = Verifier([stub_execution])

        self.assertRaises(
            VerificationException, verifier.called, 'other_command')
Example #5
0
    def test_should_not_raise_verification_exception_when_not_verifying_anything_else(self):
        execution1 = Execution(
            'command', ['-arg1', '-arg2'], 'stdin', expected=True)
        execution2 = Execution(
            'command', ['-arg1', '-arg2'], 'stdin', expected=True)
        verifier = Verifier([execution1, execution2])

        with verifier as verify:
            verify.finished()
Example #6
0
    def test_should_raise_exception_when_no_recorded_calls_available(self):
        verifier = Verifier([])

        self.assertRaises(
            VerificationException, verifier.called, 'other_command')
Example #7
0
    def test_should_return_self(self):
        verifier = Verifier([])

        actual_object = verifier.__enter__()

        self.assertTrue(verifier is actual_object)
Example #8
0
    def test_should_initialize_with_empty_list_of_executions(self):
        verifier = Verifier([])

        self.assertEqual([], verifier.executions)