# HG changeset patch # User Jeff Hammel # Date 1330645166 28800 # Node ID 26139fb1de98519d5255b56763074b83938cd606 # Parent cd88f80d1ab15642baf318f6e9f2b61659c0648d move to a more appropriate name diff -r cd88f80d1ab1 -r 26139fb1de98 tests/doctest.txt --- a/tests/doctest.txt Thu Mar 01 15:37:32 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,114 +0,0 @@ -Test simpypi -============ - -Test the WSGI app with mock requests from ``paste.fixture.TestApp``. - -The obligatory imports:: - - >>> import os - >>> import pkginfo - >>> import shutil - >>> import simpypi - >>> import subprocess - >>> import tarfile - >>> import tempfile - >>> from paste.fixture import TestApp - -The directory is initially empty:: - - >>> os.listdir(directory) - [] - -Make a test application:: - - >>> app = simpypi.SimPyPI(directory) - >>> testapp = TestApp(app) - -Upload a package:: - - >>> field = 'package' - >>> filename = 'HelloWorld-0.0.tar.gz' - >>> contents = file(os.path.join(here, filename)).read() - >>> response = testapp.post('/', upload_files=[(field, filename, contents)]) - -Ensure that package is in the right place:: - - >>> os.listdir(directory) - ['HelloWorld'] - >>> os.listdir(os.path.join(directory, 'HelloWorld')) - ['HelloWorld-0.0.tar.gz'] - -Ensure the package is what you expect it to be:: - - >>> path = os.path.join(directory, 'HelloWorld', 'HelloWorld-0.0.tar.gz') - >>> sdist = pkginfo.sdist.SDist(path) - >>> sdist.name - 'HelloWorld' - >>> sdist.version - '0.0' - >>> sdist.home_page - 'http://helloworld.example.com/' - >>> sdist.author - 'Jeff Hammel' - -Unpack the archive and ensure the files are there:: - - >>> tmpdir = tempfile.mkdtemp() - >>> archive = tarfile.TarFile.open(path) - >>> for member in archive.getmembers(): - ... archive.extract(member, path=tmpdir) - >>> os.listdir(tmpdir) - ['HelloWorld-0.0'] - >>> srcdir = os.path.join(tmpdir, 'HelloWorld-0.0') - >>> os.path.exists(os.path.join(srcdir, 'setup.py')) - True - >>> 'helloworld' in os.listdir(srcdir) - True - >>> os.listdir(os.path.join(srcdir, 'helloworld')) - ['__init__.py'] - -Install the package and inspect the installation:: - - >>> python = create_virtualenv(tmpdir) - -You should not be able to import ``helloworld`` yet:: - - >>> code = subprocess.call([python, '-c', 'import helloworld'], stdout=subprocess.PIPE, stderr=subprocess.PIPE) - >>> code - 1 - -But after installation you should:: - - >>> subprocess.call([python, 'setup.py', 'install'], cwd=srcdir, stdout=subprocess.PIPE, stderr=subprocess.PIPE) - 0 - >>> code = subprocess.call([python, '-c', 'import helloworld'], stdout=subprocess.PIPE, stderr=subprocess.PIPE) - >>> code - 0 - >>> process = subprocess.Popen([python, '-c', 'import helloworld; print helloworld.hello'], stdout=subprocess.PIPE, stderr=subprocess.PIPE) - >>> stdout, stderr = process.communicate() - >>> process.returncode - 0 - >>> stdout - 'Hello, world!\n' - >>> shutil.rmtree(tmpdir) - -Upload the same package but with the wrong name:: - - >>> shutil.rmtree(os.path.join(directory, 'HelloWorld')) - >>> os.listdir(directory) - [] - >>> response = testapp.post('/', upload_files=[(field, 'MisleadingName.tar.gz', contents)]) - >>> os.listdir(directory) - ['HelloWorld'] - >>> os.listdir(os.path.join(directory, 'HelloWorld')) - ['HelloWorld-0.0.tar.gz'] - >>> shutil.rmtree(os.path.join(directory, 'HelloWorld')) - >>> os.listdir(directory) - [] - >>> filename = 'MisleadingFilename.tar.gz' - >>> contents = file(os.path.join(here, filename)).read() - >>> response = testapp.post('/', upload_files=[(field, filename, contents)]) - >>> os.listdir(directory) - ['HelloWorld'] - >>> os.listdir(os.path.join(directory, 'HelloWorld')) - ['HelloWorld-0.0.tar.gz'] diff -r cd88f80d1ab1 -r 26139fb1de98 tests/test_wsgi.txt --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/test_wsgi.txt Thu Mar 01 15:39:26 2012 -0800 @@ -0,0 +1,114 @@ +Test simpypi +============ + +Test the WSGI app with mock requests from ``paste.fixture.TestApp``. + +The obligatory imports:: + + >>> import os + >>> import pkginfo + >>> import shutil + >>> import simpypi + >>> import subprocess + >>> import tarfile + >>> import tempfile + >>> from paste.fixture import TestApp + +The directory is initially empty:: + + >>> os.listdir(directory) + [] + +Make a test application:: + + >>> app = simpypi.SimPyPI(directory) + >>> testapp = TestApp(app) + +Upload a package:: + + >>> field = 'package' + >>> filename = 'HelloWorld-0.0.tar.gz' + >>> contents = file(os.path.join(here, filename)).read() + >>> response = testapp.post('/', upload_files=[(field, filename, contents)]) + +Ensure that package is in the right place:: + + >>> os.listdir(directory) + ['HelloWorld'] + >>> os.listdir(os.path.join(directory, 'HelloWorld')) + ['HelloWorld-0.0.tar.gz'] + +Ensure the package is what you expect it to be:: + + >>> path = os.path.join(directory, 'HelloWorld', 'HelloWorld-0.0.tar.gz') + >>> sdist = pkginfo.sdist.SDist(path) + >>> sdist.name + 'HelloWorld' + >>> sdist.version + '0.0' + >>> sdist.home_page + 'http://helloworld.example.com/' + >>> sdist.author + 'Jeff Hammel' + +Unpack the archive and ensure the files are there:: + + >>> tmpdir = tempfile.mkdtemp() + >>> archive = tarfile.TarFile.open(path) + >>> for member in archive.getmembers(): + ... archive.extract(member, path=tmpdir) + >>> os.listdir(tmpdir) + ['HelloWorld-0.0'] + >>> srcdir = os.path.join(tmpdir, 'HelloWorld-0.0') + >>> os.path.exists(os.path.join(srcdir, 'setup.py')) + True + >>> 'helloworld' in os.listdir(srcdir) + True + >>> os.listdir(os.path.join(srcdir, 'helloworld')) + ['__init__.py'] + +Install the package and inspect the installation:: + + >>> python = create_virtualenv(tmpdir) + +You should not be able to import ``helloworld`` yet:: + + >>> code = subprocess.call([python, '-c', 'import helloworld'], stdout=subprocess.PIPE, stderr=subprocess.PIPE) + >>> code + 1 + +But after installation you should:: + + >>> subprocess.call([python, 'setup.py', 'install'], cwd=srcdir, stdout=subprocess.PIPE, stderr=subprocess.PIPE) + 0 + >>> code = subprocess.call([python, '-c', 'import helloworld'], stdout=subprocess.PIPE, stderr=subprocess.PIPE) + >>> code + 0 + >>> process = subprocess.Popen([python, '-c', 'import helloworld; print helloworld.hello'], stdout=subprocess.PIPE, stderr=subprocess.PIPE) + >>> stdout, stderr = process.communicate() + >>> process.returncode + 0 + >>> stdout + 'Hello, world!\n' + >>> shutil.rmtree(tmpdir) + +Upload the same package but with the wrong name:: + + >>> shutil.rmtree(os.path.join(directory, 'HelloWorld')) + >>> os.listdir(directory) + [] + >>> response = testapp.post('/', upload_files=[(field, 'MisleadingName.tar.gz', contents)]) + >>> os.listdir(directory) + ['HelloWorld'] + >>> os.listdir(os.path.join(directory, 'HelloWorld')) + ['HelloWorld-0.0.tar.gz'] + >>> shutil.rmtree(os.path.join(directory, 'HelloWorld')) + >>> os.listdir(directory) + [] + >>> filename = 'MisleadingFilename.tar.gz' + >>> contents = file(os.path.join(here, filename)).read() + >>> response = testapp.post('/', upload_files=[(field, filename, contents)]) + >>> os.listdir(directory) + ['HelloWorld'] + >>> os.listdir(os.path.join(directory, 'HelloWorld')) + ['HelloWorld-0.0.tar.gz']