view tests/doctest.txt @ 49:ca456e08924f

add a test for misnamed files
author Jeff Hammel <jhammel@mozilla.com>
date Thu, 01 Mar 2012 14:14:12 -0800
parents cb24b5265557
children e4a97d6f2811
line wrap: on
line source

Test simpypi
============

The obligatory imports::

    >>> import os
    >>> import shutil
    >>> import simpypi
    >>> 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']

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']