cciw-website / cciw / utils / tests /

from StringIO import StringIO

import twill
from twill import commands as tc
from django.core.servers.basehttp import AdminMediaHandler
from django.core.handlers.wsgi import WSGIHandler
from django.core.urlresolvers import reverse
from import TwillCommandLoop

def make_twill_url(url):
    url = url.replace("", "")
    return url.replace("", "")

BASE = ""
def make_django_url(view, *args, **kwargs):
    return make_twill_url(BASE + reverse(view, args=args, kwargs=kwargs))

def twill_setup():
    app = AdminMediaHandler(WSGIHandler())
    twill.add_wsgi_intercept("", 8080, lambda: app)
    b = twill.get_browser()
    b._browser._factory.is_html = True # make it handle XHTML
    twill.browser = b

def twill_teardown():
    twill.remove_wsgi_intercept('', 8080)

class TwillMixin(object):
    twill_quiet = True

    def setUpClass(cls):
        if cls.twill_quiet:

    def _twill_login(self, creds):
        tc.fv(1, 'id_username', creds[0])
        tc.fv(1, 'id_password', creds[1])

    def _twill_logout(self):

    def continue_twill(self):
        cmd = TwillCommandLoop()

    def tearDownClass(cls):

# Twill snippets
# To interactively continue, finish test with this:
#   self.continue_twill()
# And add
#   twill_quiet = False
# to the class
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.