def test_is_pkg_installed(self):
        flexmock(ClHelper).should_receive('run_command')\
                          .with_args('gem list -i "foo"')
        assert self.gpm.is_pkg_installed('foo')

        flexmock(ClHelper).should_receive('run_command')\
                          .and_raise(ClException(None, None, None))
        assert not self.gpm.is_pkg_installed('baz')
    def test_works(self):
        flexmock(ClHelper).should_receive('run_command')\
                          .with_args('which gem').at_least().once()
        assert self.gpm.works()

        flexmock(ClHelper).should_receive('run_command').and_raise(
            ClException(None, None, None))
        assert not self.gpm.works()
    def test_install(self):
        pkgs = ('foo', 'bar', 'baz')

        flexmock(ClHelper).should_receive('run_command')
        assert self.ypm.install(*pkgs) == pkgs

        flexmock(ClHelper).should_receive('run_command').and_raise(
            ClException(None, None, None))
        assert self.ypm.install(*pkgs) is False
    def test_install(self):
        pkgs = ('foo', 'bar')
        flexmock(ClHelper).should_receive('run_command')\
                          .with_args('gem install "foo" "bar"',\
                                     ignore_sigint=True).at_least().once()
        assert self.gpm.install(*pkgs) == pkgs

        flexmock(ClHelper).should_receive('run_command').and_raise(
            ClException(None, None, None))
        assert not self.gpm.install(*pkgs)
    def test_is_group_installed(self):
        group = 'foo'
        flexmock(ClHelper).should_receive('run_command')\
                          .with_args('pacman -Qg "{group}"'.format(group=group))\
                          .and_return(group).at_least().once()
        assert self.ppm.is_group_installed(group) == 'foo'

        flexmock(ClHelper).should_receive('run_command').and_raise(
            ClException(None, None, None))
        assert not self.ppm.is_group_installed(group)
    def test_is_pacmanpkg_installed(self):
        pkg = 'foo'
        flexmock(ClHelper).should_receive('run_command')\
                          .with_args('pacman -Q "{pkg}"'.format(pkg=pkg))\
                          .and_return(pkg).at_least().once()
        assert self.ppm.is_pacmanpkg_installed(pkg) == 'foo'

        flexmock(ClHelper).should_receive('run_command').and_raise(
            ClException(None, None, None))
        assert not self.ppm.is_pacmanpkg_installed(pkg)
    def test_install(self):
        pkgs = ('foo', 'bar')
        flexmock(ClHelper).should_receive('run_command')\
                          .with_args('pacman -S --noconfirm "foo" "bar"',\
                                     ignore_sigint=True, as_user='******').at_least().once()
        assert self.ppm.install(*pkgs) == pkgs

        flexmock(ClHelper).should_receive('run_command').and_raise(
            ClException(None, None, None))
        assert not self.ppm.install(*pkgs)