def test_git_checkout_not_in_repository(self, mock_shell):
        options = Values(defaults={'origin': None})

        # test

        builder.git_checkout(options)

        # validation

        self.assertFalse(mock_shell.called)
    def test_git_checkout_not_in_repository(self, mock_shell):
        options = Values(defaults={'origin': None})

        # test

        builder.git_checkout(options)

        # validation

        self.assertFalse(mock_shell.called)
    def test_git_checkout_tag(self, mock_shell):
        parsed_options = {
            'origin': 'git://',
            'branch': None,
            'tag': 'mytag',
        }

        options = Values(defaults=parsed_options)

        # test

        builder.git_checkout(options)

        # validation

        mock_shell.assert_any_call('git fetch')
        mock_shell.assert_any_call('git fetch --tags')
        mock_shell.assert_any_call('git checkout %s' % options.tag)

        self.assertEqual(mock_shell.call_count, 3)
    def test_git_checkout_tag(self, mock_shell):
        parsed_options = {
            'origin': 'git://',
            'branch': None,
            'tag': 'mytag',
        }

        options = Values(defaults=parsed_options)

        # test

        builder.git_checkout(options)

        # validation

        mock_shell.assert_any_call('git fetch')
        mock_shell.assert_any_call('git fetch --tags')
        mock_shell.assert_any_call('git checkout %s' % options.tag)

        self.assertEqual(mock_shell.call_count, 3)