Exemplo n.º 1
0
    def test_run_for_all(self, instances):
        ran_for = []

        def run_for(whom):
            ran_for.append(whom)

        subject = SelectCommand('Bob', run_for, 'greets')

        subject.run_for('   all')

        assert ran_for == ['Anakin', 'Obi-Wan', 'Ahsoka']
Exemplo n.º 2
0
    def test_run_for_specific_instances(self, instances):
        ran_for = []

        def run_for(whom):
            ran_for.append(whom)

        subject = SelectCommand('Bob', run_for, 'greets')

        subject.run_for('third first third')

        assert ran_for == ['Anakin', 'Ahsoka']
Exemplo n.º 3
0
    def test_all_when_prompted_finishes(self, instances, mocker):
        mock_input = mocker.patch('__builtin__.raw_input')
        mock_input.return_value = 'all'
        ran_for = []

        def run_for(whom):
            ran_for.append(whom)

        subject = SelectCommand('Bob', run_for, 'greets')

        subject.run_for('')

        assert ran_for == ['Anakin', 'Obi-Wan', 'Ahsoka']
Exemplo n.º 4
0
    def test_run_for_with_no_input_will_prompt(self, instances, mocker):
        mock_input = mocker.patch('__builtin__.raw_input')
        mock_input.side_effect = ['first', '']
        ran_for = []

        def run_for(whom):
            ran_for.append(whom)

        subject = SelectCommand('Bob', run_for, 'greets')

        subject.run_for('')

        assert ran_for == ['Anakin']
Exemplo n.º 5
0
    def test_complains_when_instance_is_not_known(self, instances, mocker):
        mock_input = mocker.patch('__builtin__.raw_input')
        mock_input.side_effect = ['first', '']
        mock_print = mocker.patch('__builtin__.print')

        ran_for = []

        def run_for(whom):
            ran_for.append(whom)

        subject = SelectCommand('Bob', run_for, 'greets')

        subject.run_for('notaninstance')

        mock_print.assert_called_with(
            "\tno known instance called notaninstance")
        assert ran_for == ['Anakin']