Ejemplo n.º 1
0
    def test_handle_local_resolution(self, tmpdir):
        directory = Path(str(tmpdir))
        good_name = 'file.txt'
        bad_name = 'no-such-file.txt'

        existing_file = directory / good_name
        existing_file.write_text("")

        context = DependencyContext([], Language({}, 'lang'),
                                    Configuration({}, [directory], None))

        assert context._handle_local_resolution(bad_name) is None
        assert context._handle_local_resolution(good_name) == existing_file
Ejemplo n.º 2
0
    def test_fetch_file(self):
        remote_dep = _make_dep(location='remote')
        local_dep = _make_dep(location='local')
        project_dep = _make_dep(location='project')
        p1 = Path('path1')
        p2 = Path('path2')
        p3 = Path('path3')
        context = DependencyContext([], Language({}, 'lang'),
                                    Configuration({}, [], None))

        context._handle_remote_resolution = MagicMock(return_value=p1)
        context._handle_local_resolution = MagicMock(return_value=p2)
        context._handle_project_resolution = MagicMock(return_value=p3)

        r1 = context._fetch_file(remote_dep, 'remote.name')
        r2 = context._fetch_file(local_dep, 'local.name')
        r3 = context._fetch_file(project_dep, 'project.name')

        context._handle_remote_resolution.assert_called_once_with(
            'remote.name')
        context._handle_local_resolution.assert_called_once_with('local.name')
        context._handle_project_resolution.assert_called_once_with(
            'dep', 'project.name')

        assert r1 is p1
        assert r2 is p2
        assert r3 is p3