예제 #1
0
    def test(mock_get_packages_to_install, mock_remove_duplicate_dependencies,
             mock_brew_installed):
        mock_brew_installed.return_value = True

        installer = HomebrewInstaller()
        mock_get_packages_to_install.return_value = []
        mock_remove_duplicate_dependencies.return_value = mock_get_packages_to_install.return_value
        assert [] == installer.get_install_command(make_resolutions(['fake']))

        mock_get_packages_to_install.return_value = make_resolutions(
            ['subversion', 'bazaar'])
        mock_remove_duplicate_dependencies.return_value = mock_get_packages_to_install.return_value
        expected = [['brew', 'install', 'subversion'],
                    ['brew', 'install', 'bazaar']]
        # brew is always non-interactive
        for interactive in [True, False]:
            val = installer.get_install_command(['whatever'],
                                                interactive=interactive)
            assert val == expected, val

        expected = [['brew', 'uninstall', '--force', 'subversion'],
                    ['brew', 'install', 'subversion'],
                    ['brew', 'uninstall', '--force', 'bazaar'],
                    ['brew', 'install', 'bazaar']]
        val = installer.get_install_command(['whatever'], reinstall=True)
        assert val == expected, val

        mock_get_packages_to_install.return_value = make_resolutions_options([
            ('subversion', ['foo', 'bar'], ['baz']),
            ('bazaar', [], ['--with-quux'])
        ])
        mock_remove_duplicate_dependencies.return_value = mock_get_packages_to_install.return_value
        expected = [['brew', 'install', 'subversion', 'foo', 'bar', 'baz'],
                    ['brew', 'install', 'bazaar', '--with-quux']]
        val = installer.get_install_command(['whatever'])
        assert val == expected, val

        try:
            mock_get_packages_to_install.return_value = eval(
                "make_resolutions_options([('subversion', [u'f´´ßß', u'öäö'], []), (u'bazaar', [], [u'tüü'])])"
            )
        except SyntaxError:
            # Python 3.2, u'...' is not allowed, but string literals are unicode
            mock_get_packages_to_install.return_value = make_resolutions_options(
                [('subversion', ['f´´ßß', 'öäö'], []),
                 ('bazaar', [], ['tüü'])])
        mock_remove_duplicate_dependencies.return_value = mock_get_packages_to_install.return_value
        try:
            expected = eval(
                "[['brew', 'install', 'subversion', u'f´´ßß', u'öäö'], ['brew', 'install', 'bazaar', u'tüü']]"
            )
        except SyntaxError:
            # Python 3.2, u'...' is not allowed, but string literals are unicode
            expected = [['brew', 'install', 'subversion', 'f´´ßß', 'öäö'],
                        ['brew', 'install', 'bazaar', 'tüü']]
        val = installer.get_install_command(['whatever'])
        assert val == expected, val
예제 #2
0
    def test(mock_get_packages_to_install, mock_remove_duplicate_dependencies, mock_brew_installed):
        mock_brew_installed.return_value = True

        installer = HomebrewInstaller()
        mock_get_packages_to_install.return_value = []
        mock_remove_duplicate_dependencies.return_value = mock_get_packages_to_install.return_value
        assert [] == installer.get_install_command(make_resolutions(['fake']))

        mock_get_packages_to_install.return_value = make_resolutions(['subversion', 'bazaar'])
        mock_remove_duplicate_dependencies.return_value = mock_get_packages_to_install.return_value
        expected = [['brew', 'install', 'subversion'],
                    ['brew', 'install', 'bazaar']]
        # brew is always non-interactive
        for interactive in [True, False]:
            val = installer.get_install_command(['whatever'], interactive=interactive)
            assert val == expected, val

        expected = [['brew', 'uninstall', '--force', 'subversion'],
                    ['brew', 'install', 'subversion'],
                    ['brew', 'uninstall', '--force', 'bazaar'],
                    ['brew', 'install', 'bazaar']]
        val = installer.get_install_command(['whatever'], reinstall=True)
        assert val == expected, val

        mock_get_packages_to_install.return_value = make_resolutions_options(
            [('subversion', ['foo', 'bar'], ['baz']), ('bazaar', [], ['--with-quux'])])
        mock_remove_duplicate_dependencies.return_value = mock_get_packages_to_install.return_value
        expected = [['brew', 'install', 'subversion', 'foo', 'bar', 'baz'],
                    ['brew', 'install', 'bazaar', '--with-quux']]
        val = installer.get_install_command(['whatever'])
        assert val == expected, val

        try:
            mock_get_packages_to_install.return_value = eval("make_resolutions_options([('subversion', [u'f´´ßß', u'öäö'], []), (u'bazaar', [], [u'tüü'])])")
        except SyntaxError:
            # Python 3.2, u'...' is not allowed, but string literals are unicode
            mock_get_packages_to_install.return_value = make_resolutions_options(
                [('subversion', ['f´´ßß', 'öäö'], []), ('bazaar', [], ["tüü"])])
        mock_remove_duplicate_dependencies.return_value = mock_get_packages_to_install.return_value
        try:
            expected = eval("[['brew', 'install', 'subversion', u'f´´ßß', u'öäö'], ['brew', 'install', 'bazaar', u'tüü']]")
        except SyntaxError:
            # Python 3.2, u'...' is not allowed, but string literals are unicode
            expected = [['brew', 'install', 'subversion', 'f´´ßß', 'öäö'],
                        ['brew', 'install', 'bazaar', "tüü"]]
        val = installer.get_install_command(['whatever'])
        assert val == expected, val
예제 #3
0
    def test(mock_method, mock_brew_installed):
        mock_brew_installed.return_value = True
        
        installer = HomebrewInstaller()
        mock_method.return_value = []
        assert [] == installer.get_install_command(['fake'])

        mock_method.return_value = ['subversion', 'bazaar']
        expected = [['brew', 'install', 'subversion'],
                    ['brew', 'install', 'bazaar']]
        # brew is always non-interactive
        for interactive in [True, False]:
            val = installer.get_install_command(['whatever'], interactive=interactive)
            
        assert val == expected, val
        expected = [['brew', 'install', '--force', 'subversion'],
                    ['brew', 'install', '--force', 'bazaar']]
        val = installer.get_install_command(['whatever'], reinstall=True)
        assert val == expected, val
예제 #4
0
    def test(mock_method, mock_brew_installed):
        mock_brew_installed.return_value = True

        installer = HomebrewInstaller()
        mock_method.return_value = []
        assert [] == installer.get_install_command(['fake'])

        mock_method.return_value = ['subversion', 'bazaar']
        expected = [['brew', 'install', 'subversion'],
                    ['brew', 'install', 'bazaar']]
        # brew is always non-interactive
        for interactive in [True, False]:
            val = installer.get_install_command(['whatever'],
                                                interactive=interactive)

        assert val == expected, val
        expected = [['brew', 'uninstall', '--force', 'subversion'],
                    ['brew', 'install', 'subversion'],
                    ['brew', 'uninstall', '--force', 'bazaar'],
                    ['brew', 'install', 'bazaar']]
        val = installer.get_install_command(['whatever'], reinstall=True)
        assert val == expected, val
예제 #5
0
    def test(mock_get_packages_to_install, mock_remove_duplicate_dependencies, mock_brew_installed):
        mock_brew_installed.return_value = True
        
        installer = HomebrewInstaller()
        mock_get_packages_to_install.return_value = []
        mock_remove_duplicate_dependencies.return_value = mock_get_packages_to_install.return_value
        assert [] == installer.get_install_command( make_resolutions(['fake']))

        mock_get_packages_to_install.return_value = make_resolutions(['subversion', 'bazaar'])
        mock_remove_duplicate_dependencies.return_value = mock_get_packages_to_install.return_value
        expected = [['brew', 'install', 'subversion'],
                    ['brew', 'install', 'bazaar']]
        # brew is always non-interactive
        for interactive in [True, False]:
            val = installer.get_install_command(['whatever'], interactive=interactive)
            assert val == expected, val

        expected = [['brew', 'uninstall', '--force', 'subversion'],
                    ['brew', 'install', 'subversion'],
                    ['brew', 'uninstall', '--force', 'bazaar'],
                    ['brew', 'install', 'bazaar']]
        val = installer.get_install_command(['whatever'], reinstall=True)
        assert val == expected, val

        mock_get_packages_to_install.return_value = make_resolutions_options(
            [('subversion', ['foo', 'bar'], ['baz']), ('bazaar', [], ['--with-quux'])])
        mock_remove_duplicate_dependencies.return_value = mock_get_packages_to_install.return_value
        expected = [['brew', 'install', 'subversion', 'foo', 'bar', 'baz'],
                    ['brew', 'install', 'bazaar', '--with-quux']]
        val = installer.get_install_command(['whatever'])
        assert val == expected, val

        mock_get_packages_to_install.return_value = make_resolutions_options(
            [('subversion', [u'f´´ßß', u'öäö'], []), (u'bazaar', [], [u"tüü"])])
        mock_remove_duplicate_dependencies.return_value = mock_get_packages_to_install.return_value
        expected = [['brew', 'install', 'subversion', u'f´´ßß', u'öäö'],
                    ['brew', 'install', 'bazaar', u"tüü"]]
        val = installer.get_install_command(['whatever'])
        assert val == expected, val