Beispiel #1
0
def test_sync_install(from_line, lines):
    with mock.patch('prequ.sync.check_call') as check_call:
        to_install = {from_line(line) for line in lines}

        sync(to_install, set())
        check_call.assert_called_once_with(['pip', 'install', '-q'] +
                                           sorted(lines))
Beispiel #2
0
def test_sync_install_temporary_requirement_file(from_line, from_editable,
                                                 mocked_tmp_req_file):
    with mock.patch('prequ.sync.check_call') as check_call:
        to_install = {from_line('django==1.8')}
        sync(to_install, set())
        check_call.assert_called_once_with(
            ['pip', 'install', '-r', mocked_tmp_req_file.name, '-q'])
Beispiel #3
0
def test_sync_with_editable(from_editable, small_fake_package_dir):
    with mock.patch('prequ.sync.check_call') as check_call:
        to_install = {from_editable(small_fake_package_dir)}

        sync(to_install, set())
        check_call.assert_called_once_with([
            'pip', 'install', '-q', '-e',
            path_to_url(small_fake_package_dir)
        ])
Beispiel #4
0
def test_temporary_requirement_file_deleted(from_line, from_editable,
                                            mocked_tmp_file):
    with mock.patch('prequ.sync.check_call'):
        to_install = {from_line('django==1.8')}

        with mock.patch('os.unlink') as unlink:
            sync(to_install, set())

            unlink.assert_called_once_with(mocked_tmp_file.name)
Beispiel #5
0
def test_sync_with_editable_uses_abspath(from_editable,
                                         small_fake_package_dir):
    ireq = from_editable(small_fake_package_dir)
    rel_path = os.path.relpath(url_to_path(ireq.link.url))
    ireq.link.url = 'file:{}'.format(rel_path.replace(os.path.sep, '/'))
    with mock.patch('prequ.sync.check_call') as check_call:
        sync({ireq}, set())
        check_call.assert_called_once_with([
            'pip', 'install', '-q', '-e',
            path_to_url(os.path.abspath(small_fake_package_dir))
        ])
Beispiel #6
0
def test_sync_sorting_ireqs_with_editable(from_line, from_editable):
    with mock.patch('prequ.sync.check_call') as check_call:
        path_to_package = os.path.join(os.path.dirname(__file__), 'test_data',
                                       'small_fake_package')
        editable_ireq = from_editable(path_to_package)
        to_install = {
            from_line('django==1.8'),
            from_line('first==2.0.1'),
            editable_ireq,
        }
        sync(to_install, {})
        check_call.assert_called_once_with([
            'pip', 'install', '-q', 'django==1.8', 'first==2.0.1', '-e',
            str(editable_ireq.link)
        ])
Beispiel #7
0
def test_sync_with_editable_uses_abspath(from_editable, small_fake_package_dir,
                                         mocked_tmp_req_file):
    ireq = from_editable(small_fake_package_dir)
    rel_path = os.path.relpath(url_to_path(ireq.link.url))
    url = 'file:{}'.format(rel_path.replace(os.path.sep, '/'))
    if hasattr(ireq.link, '_url'):
        ireq.link._url = url
    else:
        ireq.link.url = url
    with mock.patch('prequ.sync.check_call'):
        sync({ireq}, set())

        fake_pkg_url = path_to_url(os.path.abspath(small_fake_package_dir))
        mocked_tmp_req_file.write.assert_called_once_with(
            '-e {}'.format(fake_pkg_url))
Beispiel #8
0
def test_sync_sorting_ireqs_with_editable(from_line, from_editable,
                                          mocked_tmp_req_file):
    with mock.patch('prequ.sync.check_call'):
        path_to_package = os.path.join(os.path.dirname(__file__), 'test_data',
                                       'small_fake_package')
        editable_ireq = from_editable(path_to_package)
        to_install = {
            from_line('django==1.8'),
            from_line('first==2.0.1'),
            editable_ireq,
        }
        sync(to_install, {})
        mocked_tmp_req_file.write.assert_called_once_with(
            ('django==1.8\n'
             'first==2.0.1\n'
             '-e {}').format(editable_ireq.link))
Beispiel #9
0
def test_sync_requirement_file_with_hashes(from_line, from_editable,
                                           mocked_tmp_req_file):
    with mock.patch('prequ.sync.check_call'):
        to_install = {
            from_line(
                'django==1.8',
                options={
                    'hashes': {
                        'sha256': [
                            '6a03ce2feafdd193a0ba8a26dbd9773e757d2e5d5e7933a62eac129813bd381a',
                        ]
                    }
                }),
            from_line(
                'click==4.0',
                options={
                    'hashes': {
                        'sha256': [
                            '9ab1d313f99b209f8f71a629f36833030c8d7c72282cf7756834baf567dca662',
                        ]
                    }
                }),
            from_line(
                'pytz==2017.2',
                options={
                    'hashes': {
                        'sha256': [
                            'd1d6729c85acea5423671382868627129432fba9a89ecbb248d8d1c7a9f01c67',
                            'f5c056e8f62d45ba8215e5cb8f50dfccb198b4b9fbea8500674f3443e4689589'
                        ]
                    }
                })
        }

        sync(to_install, set())

        expected = (
            'click==4.0 \\\n'
            '    --hash=sha256:9ab1d313f99b209f8f71a629f36833030c8d7c72282cf7756834baf567dca662\n'
            'django==1.8 \\\n'
            '    --hash=sha256:6a03ce2feafdd193a0ba8a26dbd9773e757d2e5d5e7933a62eac129813bd381a\n'
            'pytz==2017.2 \\\n'
            '    --hash=sha256:d1d6729c85acea5423671382868627129432fba9a89ecbb248d8d1c7a9f01c67 \\\n'
            '    --hash=sha256:f5c056e8f62d45ba8215e5cb8f50dfccb198b4b9fbea8500674f3443e4689589'
        )
        mocked_tmp_req_file.write.assert_called_once_with(expected)
Beispiel #10
0
def test_sync_requirement_file(from_line, from_editable, mocked_tmp_req_file):
    with mock.patch('prequ.sync.check_call'):
        to_install = {
            from_line('django==1.8'),
            from_editable('git+git://fake.org/x/y.git#egg=y'),
            from_line('click==4.0'),
            from_editable('git+git://fake.org/i/j.git#egg=j'),
            from_line('pytz==2017.2'),
        }

        sync(to_install, set())

        expected = ('click==4.0\n'
                    'django==1.8\n'
                    '-e git+git://fake.org/i/j.git#egg=j\n'
                    'pytz==2017.2\n'
                    '-e git+git://fake.org/x/y.git#egg=y')
        mocked_tmp_req_file.write.assert_called_once_with(expected)
Beispiel #11
0
def test_sync_sorting_ireqs(from_line):
    with mock.patch('prequ.sync.check_call') as check_call:
        to_install = {from_line('django==1.8'), from_line('first==2.0.1')}
        sync(to_install, {})
        check_call.assert_called_once_with(
            ['pip', 'install', '-q', 'django==1.8', 'first==2.0.1'])
Beispiel #12
0
def test_sync_sorting_ireqs(from_line, mocked_tmp_req_file):
    with mock.patch('prequ.sync.check_call'):
        to_install = {from_line('django==1.8'), from_line('first==2.0.1')}
        sync(to_install, {})
        mocked_tmp_req_file.write.assert_called_once_with('django==1.8\n'
                                                          'first==2.0.1')