def test_replace_signposts(self):
        ppl = PackagePathLoader()
        ppl._replace_signpost = mock.Mock()
        paths = [["site-theme", None], ["ep0", "/ep0"], ["ep1", "/ep1"], ["ep2", "/ep2"], ["allura", "/"]]
        rules = {"allura": "ep2", "site-theme": "ep1", "foo": "ep1", "ep0": "bar"}

        ppl._replace_signposts(paths, rules)

        assert_equal(paths, [["site-theme", "/ep1"], ["ep0", "/ep0"], ["allura", "/ep2"]])
    def test_replace_signposts(self):
        ppl = PackagePathLoader()
        ppl._replace_signpost = mock.Mock()
        paths = [
            ['site-theme', None],
            ['ep0', '/ep0'],
            ['ep1', '/ep1'],
            ['ep2', '/ep2'],
            ['allura', '/'],
        ]
        rules = {
            'allura': 'ep2',
            'site-theme': 'ep1',
            'foo': 'ep1',
            'ep0': 'bar',
        }

        ppl._replace_signposts(paths, rules)

        assert_equal(paths, [
            ['site-theme', '/ep1'],
            ['ep0', '/ep0'],
            ['allura', '/ep2'],
        ])
    def test_replace_signposts(self):
        ppl = PackagePathLoader()
        ppl._replace_signpost = mock.Mock()
        paths = [
                ['site-theme', None],
            ['ep0', '/ep0'],
            ['ep1', '/ep1'],
            ['ep2', '/ep2'],
            ['allura', '/'],
        ]
        rules = {
            'allura': 'ep2',
            'site-theme': 'ep1',
            'foo': 'ep1',
            'ep0': 'bar',
        }

        ppl._replace_signposts(paths, rules)

        assert_equal(paths, [
            ['site-theme', '/ep1'],
            ['ep0', '/ep0'],
            ['allura', '/ep2'],
        ])
Example #4
0
    def test_replace_signposts(self):
        ppl = PackagePathLoader()
        ppl._replace_signpost = mock.Mock()
        paths = [
            ['site-theme', None],
            ['ep0', '/ep0'],
            ['ep1', '/ep1'],
            ['ep2', '/ep2'],
            ['allura', '/'],
        ]
        rules = OrderedDict([
            ('allura', 'ep2'),
            ('site-theme', 'ep1'),
            ('foo', 'ep1'),
            ('ep0', 'bar'),
        ])

        ppl._replace_signposts(paths, rules)

        assert_equal(paths, [
            ['site-theme', '/ep1'],
            ['ep0', '/ep0'],
            ['allura', '/ep2'],
        ])
    def test_init_paths(self):
        paths = [["root", "/"], ["none", None], ["tail", "/tail"]]
        ppl = PackagePathLoader()
        ppl._load_paths = mock.Mock(return_value=paths)
        ppl._load_rules = mock.Mock(return_value=("order_rules", "repl_rules"))
        ppl._replace_signposts = mock.Mock()
        ppl._sort_paths = mock.Mock()

        output = ppl.init_paths()

        ppl._load_paths.assert_called_once_with()
        ppl._load_rules.assert_called_once_with()
        ppl._sort_paths.assert_called_once_with(paths, "order_rules")
        ppl._replace_signposts.assert_called_once_with(paths, "repl_rules")

        assert_equal(output, ["/", "/tail"])
    def test_init_paths(self):
        paths = [
            ['root', '/'],
            ['none', None],
            ['tail', '/tail'],
        ]
        ppl = PackagePathLoader()
        ppl._load_paths = mock.Mock(return_value=paths)
        ppl._load_rules = mock.Mock(return_value=('order_rules', 'repl_rules'))
        ppl._replace_signposts = mock.Mock()
        ppl._sort_paths = mock.Mock()

        output = ppl.init_paths()

        ppl._load_paths.assert_called_once_with()
        ppl._load_rules.assert_called_once_with()
        ppl._sort_paths.assert_called_once_with(paths, 'order_rules')
        ppl._replace_signposts.assert_called_once_with(paths, 'repl_rules')

        assert_equal(output, ['/', '/tail'])
    def test_init_paths(self):
        paths = [
            ['root', '/'],
            ['none', None],
            ['tail', '/tail'],
        ]
        ppl = PackagePathLoader()
        ppl._load_paths = mock.Mock(return_value=paths)
        ppl._load_rules = mock.Mock(return_value=('order_rules', 'repl_rules'))
        ppl._replace_signposts = mock.Mock()
        ppl._sort_paths = mock.Mock()

        output = ppl.init_paths()

        ppl._load_paths.assert_called_once_with()
        ppl._load_rules.assert_called_once_with()
        ppl._sort_paths.assert_called_once_with(paths, 'order_rules')
        ppl._replace_signposts.assert_called_once_with(paths, 'repl_rules')

        assert_equal(output, ['/', '/tail'])