Exemplo n.º 1
0
 def test_finalize_options_unsigned_identity_raises_exception(self):
     self.write_file(self.rc, PYPIRC)
     dist = Distribution()
     cmd = upload(dist)
     cmd.identity = True
     cmd.sign = False
     self.assertRaises(PackagingOptionError, cmd.finalize_options)
Exemplo n.º 2
0
    def test_upload(self):
        path = os.path.join(self.tmp_dir, 'xxx')
        self.write_file(path)
        command, pyversion, filename = 'xxx', '3.3', path
        dist_files = [(command, pyversion, filename)]

        # let's run it
        dist = self.create_dist(dist_files=dist_files, author='dédé')[1]
        cmd = upload(dist)
        cmd.ensure_finalized()
        cmd.repository = self.pypi.full_address
        cmd.run()

        # what did we send?
        handler, request_data = self.pypi.requests[-1]
        headers = handler.headers
        self.assertIn('dédé'.encode('utf-8'), request_data)
        self.assertIn(b'xxx', request_data)

        self.assertEqual(int(headers['content-length']), len(request_data))
        self.assertLess(int(headers['content-length']), 2500)
        self.assertTrue(
            headers['content-type'].startswith('multipart/form-data'))
        self.assertEqual(handler.command, 'POST')
        self.assertNotIn('\n', headers['authorization'])
Exemplo n.º 3
0
    def test_saved_password(self):
        # file with no password
        self.write_file(self.rc, PYPIRC_NOPASSWORD)

        # make sure it passes
        dist = Distribution()
        cmd = upload(dist)
        cmd.ensure_finalized()
        self.assertEqual(cmd.password, None)

        # make sure we get it as well, if another command
        # initialized it at the dist level
        dist.password = '******'
        cmd = upload(dist)
        cmd.finalize_options()
        self.assertEqual(cmd.password, 'xxx')
Exemplo n.º 4
0
    def test_upload_docs(self):
        path = os.path.join(self.tmp_dir, 'xxx')
        self.write_file(path)
        command, pyversion, filename = 'xxx', '3.3', path
        dist_files = [(command, pyversion, filename)]
        docs_path = os.path.join(self.tmp_dir, "build", "docs")
        os.makedirs(docs_path)
        self.write_file((docs_path, "index.html"), "yellow")
        self.write_file(self.rc, PYPIRC)

        # let's run it
        dist = self.create_dist(dist_files=dist_files, author='dédé')[1]

        cmd = upload(dist)
        cmd.get_finalized_command("build").run()
        cmd.upload_docs = True
        cmd.ensure_finalized()
        cmd.repository = self.pypi.full_address
        os.chdir(self.tmp_dir)
        cmd.run()

        handler, request_data = self.pypi.requests[-1]
        action, name, content = request_data.split(
            "----------------GHSKFJDLGDS7543FJKLFHRE75642756743254".encode(
            ))[1:4]

        self.assertIn(b'name=":action"', action)
        self.assertIn(b'doc_upload', action)
Exemplo n.º 5
0
    def test_saved_password(self):
        # file with no password
        self.write_file(self.rc, PYPIRC_NOPASSWORD)

        # make sure it passes
        dist = Distribution()
        cmd = upload(dist)
        cmd.ensure_finalized()
        self.assertEqual(cmd.password, None)

        # make sure we get it as well, if another command
        # initialized it at the dist level
        dist.password = '******'
        cmd = upload(dist)
        cmd.finalize_options()
        self.assertEqual(cmd.password, 'xxx')
Exemplo n.º 6
0
    def test_upload(self):
        path = os.path.join(self.tmp_dir, 'xxx')
        self.write_file(path)
        command, pyversion, filename = 'xxx', '3.3', path
        dist_files = [(command, pyversion, filename)]

        # let's run it
        dist = self.create_dist(dist_files=dist_files, author='dédé')[1]
        cmd = upload(dist)
        cmd.ensure_finalized()
        cmd.repository = self.pypi.full_address
        cmd.run()

        # what did we send?
        handler, request_data = self.pypi.requests[-1]
        headers = handler.headers
        self.assertIn('dédé', request_data)
        self.assertIn('xxx', request_data)

        self.assertEqual(int(headers['content-length']), len(request_data))
        self.assertLess(int(headers['content-length']), 2500)
        self.assertTrue(headers['content-type'].startswith(
            'multipart/form-data'))
        self.assertEqual(handler.command, 'POST')
        self.assertNotIn('\n', headers['authorization'])
Exemplo n.º 7
0
 def test_finalize_options_unsigned_identity_raises_exception(self):
     self.write_file(self.rc, PYPIRC)
     dist = Distribution()
     cmd = upload(dist)
     cmd.identity = True
     cmd.sign = False
     self.assertRaises(PackagingOptionError, cmd.finalize_options)
Exemplo n.º 8
0
    def test_upload_docs(self):
        path = os.path.join(self.tmp_dir, 'xxx')
        self.write_file(path)
        command, pyversion, filename = 'xxx', '3.3', path
        dist_files = [(command, pyversion, filename)]
        docs_path = os.path.join(self.tmp_dir, "build", "docs")
        os.makedirs(docs_path)
        self.write_file((docs_path, "index.html"), "yellow")
        self.write_file(self.rc, PYPIRC)

        # let's run it
        dist = self.create_dist(dist_files=dist_files, author='dédé')[1]

        cmd = upload(dist)
        cmd.get_finalized_command("build").run()
        cmd.upload_docs = True
        cmd.ensure_finalized()
        cmd.repository = self.pypi.full_address
        os.chdir(self.tmp_dir)
        cmd.run()

        handler, request_data = self.pypi.requests[-1]
        action, name, content = request_data.split(
            "----------------GHSKFJDLGDS7543FJKLFHRE75642756743254"
            .encode())[1:4]

        self.assertIn('name=":action"', action)
        self.assertIn('doc_upload', action)
Exemplo n.º 9
0
    def test_upload(self):
        tmp = self.mkdtemp()
        path = os.path.join(tmp, 'xxx')
        self.write_file(path)
        command, pyversion, filename = 'xxx', '2.6', path
        dist_files = [(command, pyversion, filename)]
        self.write_file(self.rc, PYPIRC_LONG_PASSWORD)

        # lets run it
        pkg_dir, dist = self.create_dist(dist_files=dist_files, author=u'dédé')
        cmd = upload(dist)
        cmd.ensure_finalized()
        cmd.run()

        # what did we send ?
        self.assertIn('dédé', self.last_open.req.data)
        headers = dict(self.last_open.req.headers)
        self.assert_(headers['Content-length'] > 2000)
        self.assertTrue(headers['Content-type'].startswith('multipart/form-data'))
        self.assertEquals(self.last_open.req.get_method(), 'POST')
        self.assertEquals(self.last_open.req.get_full_url(),
                          'http://pypi.python.org/pypi')
        self.assertTrue('xxx' in self.last_open.req.data)
        auth = self.last_open.req.headers['Authorization']
        self.assertFalse('\n' in auth)
Exemplo n.º 10
0
 def test_finalize_options(self):
     # new format
     self.write_file(self.rc, PYPIRC)
     dist = Distribution()
     cmd = upload(dist)
     cmd.finalize_options()
     for attr, expected in (('username', 'me'), ('password', 'secret'),
                            ('realm', 'pypi'),
                            ('repository', 'http://pypi.python.org/pypi')):
         self.assertEqual(getattr(cmd, attr), expected)
Exemplo n.º 11
0
 def test_finalize_options(self):
     # new format
     self.write_file(self.rc, PYPIRC)
     dist = Distribution()
     cmd = upload(dist)
     cmd.finalize_options()
     for attr, expected in (('username', 'me'), ('password', 'secret'),
                            ('realm', 'pypi'),
                            ('repository', 'http://pypi.python.org/pypi')):
         self.assertEqual(getattr(cmd, attr), expected)
Exemplo n.º 12
0
 def test_upload_without_files_raises_exception(self):
     dist = Distribution()
     cmd = upload(dist)
     self.assertRaises(PackagingOptionError, cmd.run)
Exemplo n.º 13
0
 def test_upload_without_files_raises_exception(self):
     dist = Distribution()
     cmd = upload(dist)
     self.assertRaises(PackagingOptionError, cmd.run)