Esempio n. 1
0
    def test_fills_proper_index(self):
        """
        Verify that pure packages are uploaded to the pure index non-pure packages are uploaded to the normal index.
        """
        user = '******'
        with devpi_server() as server_url:
            with devpi_index(server_url, user,
                             'binary') as (binary_index, password):
                with devpi_index(server_url, user, 'pure',
                                 password) as (pure_index, _):
                    main([
                        'tests/fixture/sample_pure_and_non-pure.txt',
                        binary_index, user, password,
                        '--pure-index={}'.format(pure_index)
                    ])

                    with devpi.Client(pure_index) as client:
                        self.assertTrue(
                            client.package_version_exists(
                                'progressbar', '2.2'))
                        self.assertFalse(
                            client.package_version_exists('PyYAML', '3.10'))

                    with devpi.Client(binary_index) as client:
                        self.assertFalse(
                            client.package_version_exists(
                                'progressbar', '2.2'))
                        self.assertTrue(
                            client.package_version_exists('PyYAML', '3.10'))
Esempio n. 2
0
    def test_dry_run(self):
        """
        Test that a dry run produces the same ``junit.xml`` as a run without dry-run but does not modify the server
        state.
        """
        with TestServer(USERS, INDICES) as devpi:
            with DevpiClient(devpi.server_url + '/' + INDEX, USER, PASSWORD) as client:
                client.upload('tests/fixture/pure_package/dist/test_package-0.1.dev1-py2.py3-none-any.whl')

            tempdir = tempfile.mkdtemp()
            try:
                junit_filename = os.path.join(tempdir, 'junit.xml')
                main([
                    'tests/fixture/sample_junit.txt',
                    devpi.url + '/' + INDEX,
                    USER,
                    PASSWORD,
                    '--junit-xml', junit_filename,
                    '--dry-run',
                ])

                self._assert_junit_xml_content(junit_filename)
            finally:
                shutil.rmtree(tempdir)

            self.assertFalse(package_version_exists(devpi, INDEX, 'progressbar', '2.2'))
Esempio n. 3
0
    def test_with_blacklist(self):
        with TestServer(USERS, INDICES) as devpi:

            main(['tests/fixture/sample_simple.txt', devpi.url + '/' + INDEX, USER, PASSWORD, '--blacklist={}'.format('tests/fixture/sample_no_version.txt')])

            self.assertFalse(package_version_exists(devpi, INDEX, 'progressbar', '2.2'))
            self.assertTrue(package_version_exists(devpi, INDEX, 'six', '1.7.3'))
Esempio n. 4
0
    def test_multiple_versions(self):
        with TestServer(USERS, INDICES) as devpi:

            main(['tests/fixture/sample_multiple_versions.txt', devpi.url + '/' + INDEX, USER, PASSWORD])

            self.assertTrue(package_version_exists(devpi, INDEX, 'progressbar', '2.1'))
            self.assertTrue(package_version_exists(devpi, INDEX, 'progressbar', '2.2'))
Esempio n. 5
0
    def test_reports_junit_xml(self):
        user = '******'
        with devpi_server() as server_url, devpi_index(
                server_url, user, 'wheels') as (destination_index, password):
            with devpi.Client(destination_index, user, password) as client:
                client.upload(
                    'tests/fixture/pure_package/dist/test_package-0.1_dev-py2.py3-none-any.whl'
                )

            tempdir = tempfile.mkdtemp()
            try:
                junit_filename = os.path.join(tempdir, 'junit.xml')
                main([
                    'tests/fixture/sample_junit.txt', destination_index, user,
                    password, '--junit-xml', junit_filename
                ])

                root = ET.parse(junit_filename)
                ET.dump(root)
                self._assert_test_case(
                    root, 'failure',
                    'package-that-hopefully-not-exists 99.999')
                self._assert_test_case(root, 'skipped', 'test-package 0.1-dev')

                pb_elems = root.findall(".//testcase[@name='progressbar 2.2']")
                self.assertEqual(1, len(pb_elems))
                pb_elem = pb_elems[0]
                self.assertIsNone(pb_elem.find('failure'))
                self.assertIsNone(pb_elem.find('error'))
                self.assertIsNone(pb_elem.find('skipped'))
            finally:
                shutil.rmtree(tempdir)
Esempio n. 6
0
    def test_dry_run(self):
        """
        Test that a dry run produces the same ``junit.xml`` as a run without dry-run but does not modify the server
        state.
        """
        with TestServer(USERS, INDICES) as devpi:
            with DevpiClient(devpi.server_url + '/' + INDEX, USER,
                             PASSWORD) as client:
                client.upload(
                    'tests/fixture/pure_package/dist/test_package-0.1.dev1-py2.py3-none-any.whl'
                )

            tempdir = tempfile.mkdtemp()
            try:
                junit_filename = os.path.join(tempdir, 'junit.xml')
                main([
                    'tests/fixture/sample_junit.txt',
                    devpi.url + '/' + INDEX,
                    USER,
                    PASSWORD,
                    '--junit-xml',
                    junit_filename,
                    '--dry-run',
                ])

                self._assert_junit_xml_content(junit_filename)
            finally:
                shutil.rmtree(tempdir)

            self.assertFalse(
                package_version_exists(devpi, INDEX, 'progressbar', '2.2'))
Esempio n. 7
0
    def test_not_built_if_on_pure(self):
        """
        Verify that packages are not built and re-uploaded if they are already on the pure index.
        """
        pure_user = '******'
        with devpi_server() as server_url:
            with devpi_index(server_url, 'destination',
                             'wheels') as (destination_index, _):
                with devpi_index(server_url, pure_user,
                                 'pure') as (pure_index, pure_password):
                    with devpi.Client(pure_index, pure_user,
                                      pure_password) as client:
                        client.upload(
                            'tests/fixture/pure_package/dist/test_package-0.1_dev-py2.py3-none-any.whl'
                        )
                    with patch.object(wheeler.Builder,
                                      'build',
                                      autospec=True,
                                      side_effect=Exception(
                                          'Should not build!')) as mock_build:
                        main([
                            'tests/fixture/sample_test_package.txt',
                            destination_index, pure_user, pure_password,
                            '--pure-index={}'.format(pure_index)
                        ])

                        self.assertFalse(mock_build.called)
Esempio n. 8
0
def test_multiple_versions(devpi):
    main([
        'tests/fixture/sample_multiple_versions.txt', devpi.url + '/' + INDEX,
        '--user={}'.format(USER), '--password={}'.format(PASSWORD)
    ])

    assert _package_version_exists(devpi, INDEX, 'progressbar', '2.1')
    assert _package_version_exists(devpi, INDEX, 'progressbar', '2.2')
Esempio n. 9
0
    def test_continue_on_failed(self):
        user = '******'
        with devpi_server() as server_url, devpi_index(server_url, user, 'wheels') as (destination_index, password):

            main(['tests/fixture/sample_continue_on_failed.txt', destination_index, user, password])

            with devpi.Client(destination_index) as devpi_client:
                self.assertTrue(devpi_client.package_version_exists('progressbar', '2.2'))
Esempio n. 10
0
    def test_continue_on_failed(self):
        user = "******"
        with devpi_server() as server_url, devpi_index(server_url, user, "wheels") as (destination_index, password):

            main(["tests/fixture/sample_continue_on_failed.txt", destination_index, user, password])

            with devpi.Client(destination_index) as devpi_client:
                self.assertTrue(devpi_client.package_version_exists("progressbar", "2.2"))
Esempio n. 11
0
def test_different_styles(devpi):
    main(['tests/fixture/sample_different_styles.txt', devpi.url + '/' + INDEX,
          '--user={}'.format(USER), '--password={}'.format(PASSWORD)])

    assert _package_version_exists(devpi, INDEX, 'pygments', '1.6')
    assert _package_version_exists(devpi, INDEX, 'Pygments', '1.6')
    assert _package_version_exists(devpi, INDEX, 'Django', '1.6.5')
    assert _package_version_exists(devpi, INDEX, 'django', '1.6.5')
Esempio n. 12
0
def test_batch_mode(devpi, monkeypatch):
    with patch('devpi_builder.cli.input') as mock_build:
        with pytest.raises(DevpiClientError):
            main([
                'tests/fixture/sample_simple.txt', devpi.url + '/' + INDEX,
                '--batch'
            ])
        assert not mock_build.called
Esempio n. 13
0
def test_prompt_user_pass(devpi, monkeypatch):
    monkeypatch.setattr('devpi_builder.cli.input',
                        lambda x: USER,
                        raising=False)
    monkeypatch.setattr('getpass.getpass', lambda x: PASSWORD)

    main(['tests/fixture/sample_simple.txt', devpi.url + '/' + INDEX])
    assert _package_version_exists(devpi, INDEX, 'progressbar', '2.2')
Esempio n. 14
0
def test_multiple_versions(devpi):
    main([
        'tests/fixture/sample_multiple_versions.txt', devpi.url + '/' + INDEX,
        USER, PASSWORD
    ])

    assert _package_version_exists(devpi, INDEX, 'progressbar', '2.1')
    assert _package_version_exists(devpi, INDEX, 'progressbar', '2.2')
Esempio n. 15
0
def test_with_blacklist(devpi):
    main(['tests/fixture/sample_simple.txt', devpi.url + '/' + INDEX,
          '--user={}'.format(USER),
          '--password={}'.format(PASSWORD),
          '--blacklist={}'.format('tests/fixture/sample_no_version.txt')])

    assert not _package_version_exists(devpi, INDEX, 'progressbar', '2.2')
    assert _package_version_exists(devpi, INDEX, 'six', '1.7.3')
Esempio n. 16
0
    def test_with_blacklist(self):
        user = '******'
        with devpi_server() as server_url, devpi_index(server_url, user, 'wheels') as (destination_index, password):

            main(['tests/fixture/sample_simple.txt', destination_index, user, password, '--blacklist={}'.format('tests/fixture/sample_no_version.txt')])

            with devpi.Client(destination_index) as devpi_client:
                self.assertFalse(devpi_client.package_version_exists('progressbar', '2.2'))
                self.assertTrue(devpi_client.package_version_exists('six', '1.7.3'))
Esempio n. 17
0
    def test_basic(self):
        with TestServer(USERS, INDICES) as devpi:
            main([
                'tests/fixture/sample_simple.txt', devpi.url + '/' + INDEX,
                USER, PASSWORD
            ])

            self.assertTrue(
                package_version_exists(devpi, INDEX, 'progressbar', '2.2'))
Esempio n. 18
0
    def test_different_styles(self):
        with TestServer(USERS, INDICES) as devpi:

            main(['tests/fixture/sample_different_styles.txt', devpi.url + '/' + INDEX, USER, PASSWORD])

            self.assertTrue(package_version_exists(devpi, INDEX, 'pygments', '1.6'))
            self.assertTrue(package_version_exists(devpi, INDEX, 'Pygments', '1.6'))
            self.assertTrue(package_version_exists(devpi, INDEX, 'Django', '1.6.5'))
            self.assertTrue(package_version_exists(devpi, INDEX, 'django', '1.6.5'))
Esempio n. 19
0
def test_reupload_is_safe(devpi):
    main(['tests/fixture/sample_simple.txt', devpi.url + '/' + INDEX,
          '--user={}'.format(USER), '--password={}'.format(PASSWORD)])
    main(['tests/fixture/sample_multiple_versions.txt', devpi.url + '/' + INDEX,
          '--user={}'.format(USER), '--password={}'.format(PASSWORD)])

    assert _package_version_exists(devpi, INDEX, 'progressbar', '2.1')
    assert _package_version_exists(devpi, INDEX, 'progressbar', '2.2')
    assert _package_version_exists(devpi, INDEX, 'six', '1.7.3')
Esempio n. 20
0
def test_different_styles(devpi):
    main([
        'tests/fixture/sample_different_styles.txt', devpi.url + '/' + INDEX,
        USER, PASSWORD
    ])

    assert _package_version_exists(devpi, INDEX, 'pygments', '1.6')
    assert _package_version_exists(devpi, INDEX, 'Pygments', '1.6')
    assert _package_version_exists(devpi, INDEX, 'Django', '1.6.5')
    assert _package_version_exists(devpi, INDEX, 'django', '1.6.5')
Esempio n. 21
0
    def test_different_styles(self):
        user = "******"
        with devpi_server() as server_url, devpi_index(server_url, user, "wheels") as (destination_index, password):

            main(["tests/fixture/sample_different_styles.txt", destination_index, user, password])

            with devpi.Client(destination_index) as devpi_client:
                self.assertTrue(devpi_client.package_version_exists("pygments", "1.6"))
                self.assertTrue(devpi_client.package_version_exists("Pygments", "1.6"))
                self.assertTrue(devpi_client.package_version_exists("Django", "1.6.5"))
                self.assertTrue(devpi_client.package_version_exists("django", "1.6.5"))
Esempio n. 22
0
    def test_reupload_is_safe(self):
        user = "******"
        with devpi_server() as server_url, devpi_index(server_url, user, "wheels") as (destination_index, password):

            main(["tests/fixture/sample_simple.txt", destination_index, user, password])
            main(["tests/fixture/sample_multiple_versions.txt", destination_index, user, password])

            with devpi.Client(destination_index) as devpi_client:
                self.assertTrue(devpi_client.package_version_exists("progressbar", "2.1"))
                self.assertTrue(devpi_client.package_version_exists("progressbar", "2.2"))
                self.assertTrue(devpi_client.package_version_exists("six", "1.7.3"))
Esempio n. 23
0
    def test_different_styles(self):
        user = '******'
        with devpi_server() as server_url, devpi_index(server_url, user, 'wheels') as (destination_index, password):

            main(['tests/fixture/sample_different_styles.txt', destination_index, user, password])

            with devpi.Client(destination_index) as devpi_client:
                self.assertTrue(devpi_client.package_version_exists('pygments', '1.6'))
                self.assertTrue(devpi_client.package_version_exists('Pygments', '1.6'))
                self.assertTrue(devpi_client.package_version_exists('Django', '1.6.5'))
                self.assertTrue(devpi_client.package_version_exists('django', '1.6.5'))
Esempio n. 24
0
    def test_reupload_is_safe(self):
        user = '******'
        with devpi_server() as server_url, devpi_index(server_url, user, 'wheels') as (destination_index, password):

            main(['tests/fixture/sample_simple.txt', destination_index, user, password])
            main(['tests/fixture/sample_multiple_versions.txt', destination_index, user, password])

            with devpi.Client(destination_index) as devpi_client:
                self.assertTrue(devpi_client.package_version_exists('progressbar', '2.1'))
                self.assertTrue(devpi_client.package_version_exists('progressbar', '2.2'))
                self.assertTrue(devpi_client.package_version_exists('six', '1.7.3'))
Esempio n. 25
0
def test_reports_junit_xml(devpi, tmpdir):
    with DevpiClient(devpi.server_url + '/' + INDEX,
                     USER,
                     PASSWORD) as client:
        client.upload('tests/fixture/pure_package/dist/test_package-0.1.dev1-py2.py3-none-any.whl')

    junit_filename = str(tmpdir.join('junit.xml'))
    main(['tests/fixture/sample_junit.txt', devpi.url + '/' + INDEX,
          '--user={}'.format(USER),
          '--password={}'.format(PASSWORD), '--junit-xml', junit_filename])

    _assert_junit_xml_content(junit_filename)
Esempio n. 26
0
    def test_passes_client_cert(self):
        """
        Verify that packages are not built and re-uploaded if they are already on the pure index.
        """
        PURE_INDEX='pure_index'
        with patch('devpi_builder.cli.DevpiClient') as client:
            main(['tests/fixture/sample_test_package.txt', INDEX, USER, PASSWORD, '--pure-index={}'.format(PURE_INDEX),
                  '--client-cert=some.crt'])

            client.assert_any_call(INDEX, USER, PASSWORD, client_cert='some.crt')
            client.assert_any_call(PURE_INDEX, USER, PASSWORD, client_cert='some.crt')
            self.assertEqual(2, len(client.call_args_list))  # Check that no further instances have been created
Esempio n. 27
0
def test_reupload_is_safe(devpi):
    main([
        'tests/fixture/sample_simple.txt', devpi.url + '/' + INDEX, USER,
        PASSWORD
    ])
    main([
        'tests/fixture/sample_multiple_versions.txt', devpi.url + '/' + INDEX,
        USER, PASSWORD
    ])

    assert _package_version_exists(devpi, INDEX, 'progressbar', '2.1')
    assert _package_version_exists(devpi, INDEX, 'progressbar', '2.2')
    assert _package_version_exists(devpi, INDEX, 'six', '1.7.3')
Esempio n. 28
0
    def test_not_built_if_on_pure(self):
        """
        Verify that packages are not built and re-uploaded if they are already on the pure index.
        """
        with TestServer(USERS, INDICES) as devpi:
            with DevpiClient(devpi.server_url + '/' + PURE_INDEX, USER, PASSWORD) as pure_client:
                pure_client.upload('tests/fixture/pure_package/dist/test_package-0.1_dev-py2.py3-none-any.whl')

            with patch.object(wheeler.Builder, 'build', autospec=True, side_effect=Exception('Should not build!')) as mock_build:

                main(['tests/fixture/sample_test_package.txt', devpi.url + '/' + INDEX, USER, PASSWORD, '--pure-index={}'.format(pure_client.url)])

                self.assertFalse(mock_build.called)
Esempio n. 29
0
    def test_continue_on_failed(self):
        user = '******'
        with devpi_server() as server_url, devpi_index(
                server_url, user, 'wheels') as (destination_index, password):

            main([
                'tests/fixture/sample_continue_on_failed.txt',
                destination_index, user, password
            ])

            with devpi.Client(destination_index) as devpi_client:
                self.assertTrue(
                    devpi_client.package_version_exists('progressbar', '2.2'))
Esempio n. 30
0
    def test_with_blacklist(self):
        with TestServer(USERS, INDICES) as devpi:

            main([
                'tests/fixture/sample_simple.txt', devpi.url + '/' + INDEX,
                USER, PASSWORD,
                '--blacklist={}'.format('tests/fixture/sample_no_version.txt')
            ])

            self.assertFalse(
                package_version_exists(devpi, INDEX, 'progressbar', '2.2'))
            self.assertTrue(
                package_version_exists(devpi, INDEX, 'six', '1.7.3'))
Esempio n. 31
0
def test_fills_proper_index(devpi):
    """
    Verify that pure packages are uploaded to the pure index non-pure packages are uploaded to the normal index.
    """
    main([
        'tests/fixture/sample_pure_and_non-pure.txt', devpi.url + '/' + INDEX,
        USER, PASSWORD, '--pure-index={}'.format(devpi.url + '/' + PURE_INDEX)
    ])

    assert _package_version_exists(devpi, PURE_INDEX, 'progressbar', '2.2')
    assert not _package_version_exists(devpi, PURE_INDEX, 'PyYAML', '3.10')

    assert not _package_version_exists(devpi, INDEX, 'progressbar', '2.2')
    assert _package_version_exists(devpi, INDEX, 'PyYAML', '3.10')
Esempio n. 32
0
    def test_reports_junit_xml(self):
        with TestServer(USERS, INDICES) as devpi:

            with DevpiClient(devpi.server_url + '/' + INDEX, USER, PASSWORD) as client:
                client.upload('tests/fixture/pure_package/dist/test_package-0.1.dev1-py2.py3-none-any.whl')

            tempdir = tempfile.mkdtemp()
            try:
                junit_filename = os.path.join(tempdir, 'junit.xml')
                main(['tests/fixture/sample_junit.txt', devpi.url + '/' + INDEX, USER, PASSWORD, '--junit-xml', junit_filename])

                self._assert_junit_xml_content(junit_filename)
            finally:
                shutil.rmtree(tempdir)
Esempio n. 33
0
def test_run_id(devpi, tmpdir):
    RUN_ID = 'my_run_id'

    with DevpiClient(devpi.server_url + '/' + INDEX, USER, PASSWORD) as client:
        client.upload(
            'tests/fixture/pure_package/dist/test_package-0.1.dev1-py2.py3-none-any.whl'
        )

    junit_filename = str(tmpdir.join('junit.xml'))
    main([
        'tests/fixture/sample_junit.txt', devpi.url + '/' + INDEX, USER,
        PASSWORD, '--junit-xml', junit_filename, '--run-id', RUN_ID
    ])

    _assert_junit_xml_content(junit_filename, RUN_ID)
Esempio n. 34
0
def test_passes_client_cert():
    """
    Verify that packages are not built and re-uploaded if they are already on the pure index.
    """
    PURE_INDEX='pure_index'
    with patch('devpi_builder.cli.DevpiClient') as client:
        main(['tests/fixture/sample_test_package.txt', INDEX,
              '--user={}'.format(USER),
              '--password={}'.format(PASSWORD),
              '--pure-index={}'.format(PURE_INDEX),
              '--client-cert=some.crt'])

        client.assert_any_call(INDEX, USER, PASSWORD, client_cert='some.crt')
        client.assert_any_call(PURE_INDEX, USER, PASSWORD, client_cert='some.crt')
        assert len(client.call_args_list) == 2  # Check that no further instances have been created
Esempio n. 35
0
    def test_fills_proper_index(self):
        """
        Verify that pure packages are uploaded to the pure index non-pure packages are uploaded to the normal index.
        """
        with TestServer(USERS, INDICES) as devpi:

            main(['tests/fixture/sample_pure_and_non-pure.txt', devpi.url + '/' + INDEX, USER, PASSWORD,
                          '--pure-index={}'.format(devpi.url + '/' + PURE_INDEX)
            ])

            self.assertTrue(package_version_exists(devpi, PURE_INDEX, 'progressbar', '2.2'))
            self.assertFalse(package_version_exists(devpi, PURE_INDEX, 'PyYAML', '3.10'))

            self.assertFalse(package_version_exists(devpi, INDEX, 'progressbar', '2.2'))
            self.assertTrue(package_version_exists(devpi, INDEX, 'PyYAML', '3.10'))
Esempio n. 36
0
    def test_different_styles(self):
        with TestServer(USERS, INDICES) as devpi:

            main([
                'tests/fixture/sample_different_styles.txt',
                devpi.url + '/' + INDEX, USER, PASSWORD
            ])

            self.assertTrue(
                package_version_exists(devpi, INDEX, 'pygments', '1.6'))
            self.assertTrue(
                package_version_exists(devpi, INDEX, 'Pygments', '1.6'))
            self.assertTrue(
                package_version_exists(devpi, INDEX, 'Django', '1.6.5'))
            self.assertTrue(
                package_version_exists(devpi, INDEX, 'django', '1.6.5'))
Esempio n. 37
0
def test_not_built_if_on_pure(devpi):
    """
    Verify that packages are not built and re-uploaded if they are already on the pure index.
    """
    with DevpiClient(devpi.server_url + '/' + PURE_INDEX,
                     USER,
                     PASSWORD) as pure_client:
        pure_client.upload('tests/fixture/pure_package/dist/test_package-0.1.dev1-py2.py3-none-any.whl')

        with patch.object(
                wheeler.Builder, 'build', autospec=True, side_effect=Exception('Should not build!')
        ) as mock_build:
            main(['tests/fixture/sample_test_package.txt', devpi.url + '/' + INDEX,
                  '--user={}'.format(USER),
                  '--password={}'.format(PASSWORD), '--pure-index={}'.format(pure_client.url)])
            assert not mock_build.called
Esempio n. 38
0
    def test_not_built_if_on_pure(self):
        """
        Verify that packages are not built and re-uploaded if they are already on the pure index.
        """
        pure_user = '******'
        with devpi_server() as server_url:
            with devpi_index(server_url, 'destination', 'wheels') as (destination_index, _):
                with devpi_index(server_url, pure_user, 'pure') as (pure_index, pure_password):
                    with devpi.Client(pure_index, pure_user, pure_password) as client:
                        client.upload('tests/fixture/pure_package/dist/test_package-0.1_dev-py2.py3-none-any.whl')
                    with patch.object(wheeler.Builder, 'build', autospec=True, side_effect=Exception('Should not build!')) as mock_build:
                        main(['tests/fixture/sample_test_package.txt', destination_index, pure_user, pure_password,
                              '--pure-index={}'.format(pure_index)
                        ])

                        self.assertFalse(mock_build.called)
Esempio n. 39
0
    def test_with_blacklist(self):
        user = '******'
        with devpi_server() as server_url, devpi_index(
                server_url, user, 'wheels') as (destination_index, password):

            main([
                'tests/fixture/sample_simple.txt', destination_index, user,
                password,
                '--blacklist={}'.format('tests/fixture/sample_no_version.txt')
            ])

            with devpi.Client(destination_index) as devpi_client:
                self.assertFalse(
                    devpi_client.package_version_exists('progressbar', '2.2'))
                self.assertTrue(
                    devpi_client.package_version_exists('six', '1.7.3'))
Esempio n. 40
0
def test_handles_non_ascii_build_output(devpi, tmpdir, monkeypatch):
    monkeypatch.setenv('PIP_INDEX_URL', devpi.url + '/' + PURE_INDEX)

    with DevpiClient(devpi.server_url + '/' + PURE_INDEX,
                     USER,
                     PASSWORD) as client:
        client.upload('tests/fixture/non-ascii_package/dist/non-ascii-package-0.1.dev1.tar.gz')

    junit_filename = str(tmpdir.join('junit.xml'))

    # our main assertion is that the main does not fail
    main(['tests/fixture/sample_non-ascii.txt', devpi.url + '/' + INDEX,
          '--user={}'.format(USER),
          '--password={}'.format(PASSWORD), '--junit-xml', junit_filename])

    # check that the build failure shows up in the build output
    assert 'No non-ascii 4 you!' in open(junit_filename).read()
Esempio n. 41
0
    def test_with_blacklist(self):
        user = "******"
        with devpi_server() as server_url, devpi_index(server_url, user, "wheels") as (destination_index, password):

            main(
                [
                    "tests/fixture/sample_simple.txt",
                    destination_index,
                    user,
                    password,
                    "--blacklist={}".format("tests/fixture/sample_no_version.txt"),
                ]
            )

            with devpi.Client(destination_index) as devpi_client:
                self.assertFalse(devpi_client.package_version_exists("progressbar", "2.2"))
                self.assertTrue(devpi_client.package_version_exists("six", "1.7.3"))
Esempio n. 42
0
def test_fills_proper_index(devpi):
    """
    Verify that pure packages are uploaded to the pure index non-pure packages are uploaded to the normal index.
    """
    main([
        'tests/fixture/sample_pure_and_non-pure.txt',
        devpi.url + '/' + INDEX,
        '--user={}'.format(USER),
        '--password={}'.format(PASSWORD),
        '--pure-index={}'.format(devpi.url + '/' + PURE_INDEX)
    ])

    assert _package_version_exists(devpi, PURE_INDEX, 'progressbar', '2.2')
    assert not _package_version_exists(devpi, PURE_INDEX, 'PyYAML', '3.10')

    assert not _package_version_exists(devpi, INDEX, 'progressbar', '2.2')
    assert _package_version_exists(devpi, INDEX, 'PyYAML', '3.10')
Esempio n. 43
0
    def test_reupload_is_safe(self):
        with TestServer(USERS, INDICES) as devpi:

            main([
                'tests/fixture/sample_simple.txt', devpi.url + '/' + INDEX,
                USER, PASSWORD
            ])
            main([
                'tests/fixture/sample_multiple_versions.txt',
                devpi.url + '/' + INDEX, USER, PASSWORD
            ])

            self.assertTrue(
                package_version_exists(devpi, INDEX, 'progressbar', '2.1'))
            self.assertTrue(
                package_version_exists(devpi, INDEX, 'progressbar', '2.2'))
            self.assertTrue(
                package_version_exists(devpi, INDEX, 'six', '1.7.3'))
Esempio n. 44
0
    def test_fills_proper_index(self):
        """
        Verify that pure packages are uploaded to the pure index non-pure packages are uploaded to the normal index.
        """
        user = '******'
        with devpi_server() as server_url:
            with devpi_index(server_url, user, 'binary') as (binary_index, password):
                with devpi_index(server_url, user, 'pure', password) as (pure_index, _):
                    main(['tests/fixture/sample_pure_and_non-pure.txt', binary_index, user, password,
                          '--pure-index={}'.format(pure_index)
                    ])

                    with devpi.Client(pure_index) as client:
                        self.assertTrue(client.package_version_exists('progressbar', '2.2'))
                        self.assertFalse(client.package_version_exists('PyYAML', '3.10'))

                    with devpi.Client(binary_index) as client:
                        self.assertFalse(client.package_version_exists('progressbar', '2.2'))
                        self.assertTrue(client.package_version_exists('PyYAML', '3.10'))
Esempio n. 45
0
    def test_different_styles(self):
        user = '******'
        with devpi_server() as server_url, devpi_index(
                server_url, user, 'wheels') as (destination_index, password):

            main([
                'tests/fixture/sample_different_styles.txt', destination_index,
                user, password
            ])

            with devpi.Client(destination_index) as devpi_client:
                self.assertTrue(
                    devpi_client.package_version_exists('pygments', '1.6'))
                self.assertTrue(
                    devpi_client.package_version_exists('Pygments', '1.6'))
                self.assertTrue(
                    devpi_client.package_version_exists('Django', '1.6.5'))
                self.assertTrue(
                    devpi_client.package_version_exists('django', '1.6.5'))
Esempio n. 46
0
    def test_reports_junit_xml(self):
        with TestServer(USERS, INDICES) as devpi:

            with DevpiClient(devpi.server_url + '/' + INDEX, USER,
                             PASSWORD) as client:
                client.upload(
                    'tests/fixture/pure_package/dist/test_package-0.1.dev1-py2.py3-none-any.whl'
                )

            tempdir = tempfile.mkdtemp()
            try:
                junit_filename = os.path.join(tempdir, 'junit.xml')
                main([
                    'tests/fixture/sample_junit.txt', devpi.url + '/' + INDEX,
                    USER, PASSWORD, '--junit-xml', junit_filename
                ])

                self._assert_junit_xml_content(junit_filename)
            finally:
                shutil.rmtree(tempdir)
Esempio n. 47
0
    def test_reupload_is_safe(self):
        user = '******'
        with devpi_server() as server_url, devpi_index(
                server_url, user, 'wheels') as (destination_index, password):

            main([
                'tests/fixture/sample_simple.txt', destination_index, user,
                password
            ])
            main([
                'tests/fixture/sample_multiple_versions.txt',
                destination_index, user, password
            ])

            with devpi.Client(destination_index) as devpi_client:
                self.assertTrue(
                    devpi_client.package_version_exists('progressbar', '2.1'))
                self.assertTrue(
                    devpi_client.package_version_exists('progressbar', '2.2'))
                self.assertTrue(
                    devpi_client.package_version_exists('six', '1.7.3'))
Esempio n. 48
0
    def test_fills_proper_index(self):
        """
        Verify that pure packages are uploaded to the pure index non-pure packages are uploaded to the normal index.
        """
        with TestServer(USERS, INDICES) as devpi:

            main([
                'tests/fixture/sample_pure_and_non-pure.txt',
                devpi.url + '/' + INDEX, USER, PASSWORD,
                '--pure-index={}'.format(devpi.url + '/' + PURE_INDEX)
            ])

            self.assertTrue(
                package_version_exists(devpi, PURE_INDEX, 'progressbar',
                                       '2.2'))
            self.assertFalse(
                package_version_exists(devpi, PURE_INDEX, 'PyYAML', '3.10'))

            self.assertFalse(
                package_version_exists(devpi, INDEX, 'progressbar', '2.2'))
            self.assertTrue(
                package_version_exists(devpi, INDEX, 'PyYAML', '3.10'))
Esempio n. 49
0
def test_dry_run(devpi, tmpdir):
    """
    Test that a dry run produces the same ``junit.xml`` as a run without dry-run but does not modify the server
    state.
    """
    with DevpiClient(devpi.server_url + '/' + INDEX,
                     USER, PASSWORD) as client:
        client.upload('tests/fixture/pure_package/dist/test_package-0.1.dev1-py2.py3-none-any.whl')

    junit_filename = str(tmpdir.join('junit.xml'))
    main([
        'tests/fixture/sample_junit.txt',
        devpi.url + '/' + INDEX,
        '--user={}'.format(USER),
        '--password={}'.format(PASSWORD),
        '--junit-xml', junit_filename,
        '--dry-run',
    ])

    _assert_junit_xml_content(junit_filename)

    assert not _package_version_exists(devpi, INDEX, 'progressbar', '2.2')
Esempio n. 50
0
    def test_reports_junit_xml(self):
        user = '******'
        with devpi_server() as server_url, devpi_index(server_url, user, 'wheels') as (destination_index, password):
            with devpi.Client(destination_index, user, password) as client:
                client.upload('tests/fixture/pure_package/dist/test_package-0.1_dev-py2.py3-none-any.whl')

            tempdir = tempfile.mkdtemp()
            try:
                junit_filename = os.path.join(tempdir, 'junit.xml')
                main(['tests/fixture/sample_junit.txt', destination_index, user, password, '--junit-xml', junit_filename])

                root = ET.parse(junit_filename)
                ET.dump(root)
                self._assert_test_case(root, 'failure', 'package-that-hopefully-not-exists 99.999')
                self._assert_test_case(root, 'skipped', 'test-package 0.1-dev')

                pb_elems = root.findall(".//testcase[@name='progressbar 2.2']")
                self.assertEqual(1, len(pb_elems))
                pb_elem = pb_elems[0]
                self.assertIsNone(pb_elem.find('failure'))
                self.assertIsNone(pb_elem.find('error'))
                self.assertIsNone(pb_elem.find('skipped'))
            finally:
                shutil.rmtree(tempdir)
Esempio n. 51
0
    def test_reports_junit_xml(self):
        with TestServer(USERS, INDICES) as devpi:

            with DevpiClient(devpi.server_url + '/' + INDEX, USER, PASSWORD) as client:
                client.upload('tests/fixture/pure_package/dist/test_package-0.1_dev-py2.py3-none-any.whl')

            tempdir = tempfile.mkdtemp()
            try:
                junit_filename = os.path.join(tempdir, 'junit.xml')
                main(['tests/fixture/sample_junit.txt', devpi.url + '/' + INDEX, USER, PASSWORD, '--junit-xml', junit_filename])

                root = ET.parse(junit_filename)
                ET.dump(root)
                self._assert_test_case(root, 'failure', 'package-that-hopefully-not-exists 99.999')
                self._assert_test_case(root, 'skipped', 'test-package 0.1-dev')

                pb_elems = root.findall(".//testcase[@name='progressbar 2.2']")
                self.assertEqual(1, len(pb_elems))
                pb_elem = pb_elems[0]
                self.assertIsNone(pb_elem.find('failure'))
                self.assertIsNone(pb_elem.find('error'))
                self.assertIsNone(pb_elem.find('skipped'))
            finally:
                shutil.rmtree(tempdir)
Esempio n. 52
0
def test_batch_mode(devpi, monkeypatch):
    with patch('devpi_builder.cli.input') as mock_build:
        with pytest.raises(DevpiClientError):
            main(['tests/fixture/sample_simple.txt', devpi.url + '/' + INDEX, '--batch'])
        assert not mock_build.called
Esempio n. 53
0
def test_read_environment(devpi, monkeypatch):
    monkeypatch.setenv('DEVPI_USER', USER)
    monkeypatch.setenv('DEVPI_PASSWORD', PASSWORD)
    main(['tests/fixture/sample_simple.txt', devpi.url + '/' + INDEX])
    assert _package_version_exists(devpi, INDEX, 'progressbar', '2.2')
Esempio n. 54
0
def test_continue_on_failed(devpi):
    main(['tests/fixture/sample_continue_on_failed.txt', devpi.url + '/' + INDEX,
          '--user={}'.format(USER), '--password={}'.format(PASSWORD)])
    assert _package_version_exists(devpi, INDEX, 'progressbar', '2.2')
Esempio n. 55
0
def test_prompt_user_pass(devpi, monkeypatch):
    monkeypatch.setattr('devpi_builder.cli.input', lambda x: USER, raising=False)
    monkeypatch.setattr('getpass.getpass', lambda x: PASSWORD)

    main(['tests/fixture/sample_simple.txt', devpi.url + '/' + INDEX])
    assert _package_version_exists(devpi, INDEX, 'progressbar', '2.2')