Exemplo n.º 1
0
    def test_it(self):
        orig = contentsSet([
            fs.fsFile('/cheddar', strict=False),
            fs.fsFile('/sporks-suck', strict=False),
            fs.fsDir('/foons-rule', strict=False),
            fs.fsDir('/mango', strict=False)
        ])

        engine = fake_engine(mode=const.INSTALL_MODE)
        def run(func):
            new = contentsSet(orig)
            self.kls(func)(engine, {'new_cset':new})
            return new

        self.assertEqual(orig, run(lambda s:False))
        self.assertEqual([], run(post_curry(isinstance, fs.fsDir)).dirs())
        self.assertEqual(orig.files(),
            run(post_curry(isinstance, fs.fsDir)).dirs(True))

        # check noisyness.
        info = []
        engine = fake_engine(observer=fake_reporter(info=info.append),
            mode=const.REPLACE_MODE)

        run(lambda s:False)
        self.assertFalse(info)
        run(post_curry(isinstance, fs.fsDir))
        self.assertEqual(len(info), 2)

        # ensure only the relevant files show.
        self.assertNotIn('/cheddar', ' '.join(info))
        self.assertNotIn('/sporks-suck', ' '.join(info))
        self.assertIn('/foons-rule', ' '.join(info))
        self.assertIn('/mango', ' '.join(info))
Exemplo n.º 2
0
    def test_observer_warn(self):
        warnings = []
        engine = fake_engine(observer=fake_reporter(warn=warnings.append))

        self._trigger_override = self.kls()

        def run(fs_objs, fix_perms=False):
            self.kls(fix_perms=fix_perms).trigger(engine, contentsSet(fs_objs))

        run([fs.fsFile('/foon', mode=0770, strict=False)])
Exemplo n.º 3
0
    def test_observer_warn(self):
        warnings = []
        engine = fake_engine(observer=fake_reporter(warn=warnings.append))

        self._trigger_override = self.kls()

        def run(fs_objs, fix_perms=False):
            self.kls(fix_perms=fix_perms).trigger(engine,
                contentsSet(fs_objs))

        run([fs.fsFile('/foon', mode=0770, strict=False)])
Exemplo n.º 4
0
    def test_it(self):
        orig = contentsSet([
            fs.fsFile('/cheddar', strict=False),
            fs.fsFile('/sporks-suck', strict=False),
            fs.fsDir('/foons-rule', strict=False),
            fs.fsDir('/mango', strict=False)
        ])

        engine = fake_engine(mode=const.INSTALL_MODE)

        def run(func):
            new = contentsSet(orig)
            self.kls(func)(engine, {'new_cset': new})
            return new

        self.assertEqual(orig, run(lambda s: False))
        self.assertEqual([], run(post_curry(isinstance, fs.fsDir)).dirs())
        self.assertEqual(
            sorted(orig.files()),
            sorted(run(post_curry(isinstance, fs.fsDir)).dirs(True)))

        # check noisyness.
        info = []
        engine = fake_engine(observer=fake_reporter(info=info.append),
                             mode=const.REPLACE_MODE)

        run(lambda s: False)
        self.assertFalse(info)
        run(post_curry(isinstance, fs.fsDir))
        self.assertEqual(len(info), 2)

        # ensure only the relevant files show.
        self.assertNotIn('/cheddar', ' '.join(info))
        self.assertNotIn('/sporks-suck', ' '.join(info))
        self.assertIn('/foons-rule', ' '.join(info))
        self.assertIn('/mango', ' '.join(info))
Exemplo n.º 5
0
def make_fake_reporter(**kwargs):
    kwargs = dict(
        (key, partial(_render_msg, val)) for key, val in kwargs.iteritems())
    return fake_reporter(**kwargs)
Exemplo n.º 6
0
def make_fake_reporter(**kwargs):
    kwargs = dict((key, partial(_render_msg, val))
                  for key, val in kwargs.iteritems())
    return fake_reporter(**kwargs)