def test_missing_taps(self, tmpdir, debug, verbose, installed, brewed): cider = Cider(False, debug, verbose, cider_dir=str(tmpdir)) cider.brew = MagicMock() cider.brew.tap = MagicMock(return_value="\n".join(brewed)) missing = set(brewed) - set(installed) assert cider.missing_taps() == sorted(missing)
def test_rm(self, tmpdir, cask, debug, verbose, formulas): cider = Cider(cask, debug, verbose, cider_dir=str(tmpdir)) cider.brew = MagicMock() cider.rm(*formulas) cider.brew.rm.assert_called_once_with(*formulas) key = "casks" if cask else "formulas" for formula in formulas: assert formula not in cider.read_bootstrap().get(key, [])
def test_missing(self, tmpdir, cask, debug, verbose, installed, brewed): orphans = [] def generate_uses(): uses = {} for formula in brewed: subset = [x for x in installed if x != formula] if subset and random.choice([True, False]): uses[formula] = random.sample( subset, random.randint(1, len(subset))) else: orphans.append(formula) return lambda x: uses.get(x, []) cider = Cider(cask, debug, verbose, cider_dir=str(tmpdir)) cider.brew = MagicMock() cider.brew.ls = MagicMock(return_value=brewed) cider.brew.uses = MagicMock(side_effect=generate_uses()) cider.installed = MagicMock(return_value=installed) assert cider.missing() == sorted(orphans)
def test_missing(self, tmpdir, cask, debug, verbose, installed, brewed): orphans = [] def generate_uses(): uses = {} for formula in brewed: subset = [x for x in installed if x != formula] if subset and random.choice([True, False]): uses[formula] = random.sample(subset, random.randint( 1, len(subset) )) else: orphans.append(formula) return lambda x: uses.get(x, []) cider = Cider(cask, debug, verbose, cider_dir=str(tmpdir)) cider.brew = MagicMock() cider.brew.ls = MagicMock(return_value=brewed) cider.brew.uses = MagicMock(side_effect=generate_uses()) cider.installed = MagicMock(return_value=installed) assert cider.missing() == sorted(orphans)
def test_untap(self, tmpdir, debug, verbose, tap): cider = Cider(False, debug, verbose, cider_dir=str(tmpdir)) cider.brew = MagicMock() cider.untap(tap) cider.brew.untap.assert_called_with(tap) assert tap not in cider.read_bootstrap().get("taps", [])