Esempio n. 1
0
    def setup(
        self,
        login=None,
        password=None,
        service_url="https://bramka.play.pl",
        login_url="https://logowanie.play.pl/p4-idp2/LoginForm.do",
        logout_url="https://logowanie.play.pl/p4-idp2/LogoutUser",
    ):
        self.SERVICE_URL = service_url
        self.LOGIN_URL = login_url
        self.LOGOUT_URL = logout_url
        self.MY_PHONE_NUMBER = login
        self.MY_PASSWORD = password

        web.config("readonly_controls_writeable", True)
        web.agent(self.MY_HTTP_AGENT)

        web.go(self.SERVICE_URL)
        web.submit()
        web.code(200)
        web.formvalue("loginForm", "login", self.MY_PHONE_NUMBER)
        web.formvalue("loginForm", "password", self.MY_PASSWORD)
        web.submit()
        web.code(200)
        self._retry_find("editableSmsComposeForm", 5)
Esempio n. 2
0
def test_global_form():
    """
    test the handling of global form elements
    """
    b = commands.get_browser()
    commands.config('use_tidy', '0')

    commands.go(url)
    commands.go('/effed_up_forms')
    forms = b.get_all_forms()
    assert len(forms) == 2
Esempio n. 3
0
def test_global_form():
    """
    test the handling of global form elements
    """
    b = commands.get_browser()
    commands.config('use_tidy', '0')

    commands.go(url)
    commands.go('/effed_up_forms')
    forms = list(b._browser.forms())
    assert len(forms) == 1
    assert b._browser.global_form()
Esempio n. 4
0
def test2():
    config('require_tidy', 0)
    _save, utils._tidy_cmd = utils._tidy_cmd, [""]
    
    try:
        (output, errors) = utils.run_tidy(bad_html)
        (output, errors) = utils.run_tidy(bad_html)
    finally:
        utils._tidy_cmd = _save

    assert output is None
    assert errors is None
    config('require_tidy', 1)
Esempio n. 5
0
def test2():
    config('require_tidy', 0)
    _save, utils._tidy_cmd = utils._tidy_cmd, [""]
    
    try:
        (output, errors) = utils.run_tidy(bad_html)
        (output, errors) = utils.run_tidy(bad_html)
    finally:
        utils._tidy_cmd = _save

    assert output is None
    assert errors is None
    config('require_tidy', 1)
Esempio n. 6
0
def test_effed_up_forms2():
    """
    should always succeed; didn't back ~0.7.
    """
    commands.config('use_tidy', '1')
    commands.config('use_BeautifulSoup', '1')
    commands.config('allow_parse_errors', '0')

    commands.go(url)
    commands.go('/effed_up_forms2')

    b = commands.get_browser()
    forms = b.get_all_forms()
    form = forms[0]
    inputs = [i for i in form.inputs]
    assert len(inputs) == 3, \
    "you must have 'tidy' installed for this test to pass"

    # with a more correct form parser this would work like the above.
    commands.config('use_tidy', '0')
    commands.reload()
    forms = b.get_all_forms()
    form = forms[0]
    inputs = [i for i in form.inputs]
    assert len(inputs) == 3, "lxml should find 3 form inputs"
Esempio n. 7
0
def configure_twill(tc):
    """Configure twill to be used by LinkChecker.
    Note that there is no need to set a proxy since twill uses the same
    ones (provided from urllib) as LinkChecker does.
    """
    # make sure readonly controls are writeable (might be needed)
    tc.config("readonly_controls_writeable", True)
    # fake IE 6.0 to talk sense into some sites (eg. SourceForge)
    tc.agent("Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)")
    # tell twill to shut up
    tc.OUT = dummy.Dummy()
    from twill import browser
    browser.OUT = dummy.Dummy()
    # set debug level
    if log.is_debug(LOG_CHECK):
        tc.debug("http", 1)
Esempio n. 8
0
def configure_twill (tc):
    """Configure twill to be used by LinkChecker.
    Note that there is no need to set a proxy since twill uses the same
    ones (provided from urllib) as LinkChecker does.
    """
    # make sure readonly controls are writeable (might be needed)
    tc.config("readonly_controls_writeable", True)
    # fake IE 6.0 to talk sense into some sites (eg. SourceForge)
    tc.agent("Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)")
    # tell twill to shut up
    tc.OUT = dummy.Dummy()
    from twill import browser
    browser.OUT = dummy.Dummy()
    # set debug level
    if log.is_debug(LOG_CHECK):
        tc.debug("http", 1)
Esempio n. 9
0
def assign(ssid, content):
    cmd.go('/py/teacher/assignment/new/')
    cmd.find(content[0])
    soup = BeautifulSoup(cmd.show())
    cmd.go(soup.find('a', text=content[0]).parent['href'])
    soup = BeautifulSoup(cmd.show())
    cmd.go(soup.find('a', text=content[1]).parent['href'])
    soup = BeautifulSoup(cmd.show())
    assignment = soup.find(
        'b', text=content[2]).parent.parent.parent.find('input')['value']
    cmd.fv(2, 'task', assignment)
    cmd.config('readonly_controls_writeable', '+')
    cmd.fv(2, 'mainform_force_next', 'yes')
    cmd.submit()
    b = cmd.get_browser()
    mb = b._browser
    r = mb.open(b.get_url(), 'studentset_id=%d' % ssid)
    cmd.submit()
Esempio n. 10
0
def test_tidy():
    """
    test parsing of tidy-processed HTML.
    """
    b = commands.get_browser()

    commands.config('use_tidy', '1')
    commands.config('use_BeautifulSoup', '0')
    commands.config('allow_parse_errors', '0')

    commands.go(url)

    ###

    commands.go('/tidy_fixable_html')

    forms = b.get_all_forms()
    assert len(forms) == 1, \
 "you must have 'tidy' installed for this test to pass"

    ###

    commands.go('/BS_fixable_html')
    forms = b.get_all_forms()
    assert len(forms) == 1, \
            "there should be one mangled form on this page"
Esempio n. 11
0
def test_raw():
    """
    test parsing of raw, unfixed HTML.
    """
    b = commands.get_browser()

    commands.config('use_tidy', '0')
    commands.config('use_BeautifulSoup', '0')
    commands.config('allow_parse_errors', '0')

    commands.go(url)

    ###
    # Apparently, mechanize is more tolerant than it used to be.

    # commands.go('/tidy_fixable_html')

    # forms = [ i for i in b._browser.forms() ]
    # logging.info("forms: %s", forms)
    # assert len(forms) == 0, "there should be no correct forms on this page"

    ###

    commands.go('/BS_fixable_html')
    forms = [ i for i in b._browser.forms() ]
    assert len(forms) == 1, "there should be one mangled form on this page"
Esempio n. 12
0
def test_BeautifulSoup():
    """
    test parsing of BS-processed HTML.
    """
    b = commands.get_browser()

    commands.config('use_tidy', '0')
    commands.config('use_BeautifulSoup', '1')
    commands.config('allow_parse_errors', '0')

    commands.go(url)

    ###

    commands.go('/tidy_fixable_html')

    forms = [i for i in b._browser.forms()]
    assert len(forms) == 0, \
           "there should be no correct forms on this page"

    ###

    commands.go('/BS_fixable_html')
    forms = [i for i in b._browser.forms()]
    assert len(forms) == 1, \
           "there should be one mangled form on this page"
Esempio n. 13
0
def test_BeautifulSoup():
    """
    test parsing of BS-processed HTML.
    """
    b = commands.get_browser()

    commands.config('use_tidy', '0')
    commands.config('use_BeautifulSoup', '1')
    commands.config('allow_parse_errors', '0')

    commands.go(url)

    ###
    
    commands.go('/tidy_fixable_html')

    forms = [ i for i in b._browser.forms() ]
    assert len(forms) == 0, \
           "there should be no correct forms on this page"

    ###

    commands.go('/BS_fixable_html')
    forms = [ i for i in b._browser.forms() ]
    assert len(forms) == 1, \
           "there should be one mangled form on this page"
Esempio n. 14
0
def test_BeautifulSoup():
    """
    test parsing of BS-processed HTML.
    """
    b = commands.get_browser()

    commands.config('use_tidy', '0')
    commands.config('use_BeautifulSoup', '1')
    commands.config('allow_parse_errors', '0')

    commands.go(url)

    ###

    commands.go('/tidy_fixable_html')

    forms = b.get_all_forms()
    assert len(forms) == 1, "lxml should find one form on this page"

    ###

    commands.go('/BS_fixable_html')
    forms = b.get_all_forms()
    assert len(forms) == 1, \
           "there should be one mangled form on this page"
Esempio n. 15
0
def test_tidy():
    """
    test parsing of tidy-processed HTML.
    """
    b = commands.get_browser()

    commands.config('use_tidy', '1')
    commands.config('use_BeautifulSoup', '0')
    commands.config('allow_parse_errors', '0')

    commands.go(url)

    ###
    
    commands.go('/tidy_fixable_html')

    forms = [ i for i in b._browser.forms() ]
    assert len(forms) == 1, \
	"you must have 'tidy' installed for this test to pass"

    ###

    commands.go('/BS_fixable_html')
    forms = [ i for i in b._browser.forms() ]
    assert len(forms) == 1, \
           "there should be one mangled form on this page"
Esempio n. 16
0
def test_allow_parse_errors():
    """
    test nice parsing.
    """
    b = commands.get_browser()

    commands.config('use_tidy', '0')
    commands.config('use_BeautifulSoup', '1')
    commands.config('allow_parse_errors', '1')

    commands.go(url)

    commands.go('/unfixable_html')
    b.get_all_forms()
Esempio n. 17
0
def test_allow_parse_errors():
    """
    test nice parsing.
    """
    b = commands.get_browser()

    commands.config('use_tidy', '0')
    commands.config('use_BeautifulSoup', '1')
    commands.config('allow_parse_errors', '1')

    commands.go(url)

    commands.go('/unfixable_html')
    b._browser.forms()
Esempio n. 18
0
def test_effed_up_forms2():
    """
    should always succeed; didn't back ~0.7.
    """
    commands.config('use_tidy', '1')
    commands.config('use_BeautifulSoup', '1')
    commands.config('allow_parse_errors', '0')

    commands.go(url)
    commands.go('/effed_up_forms2')

    b = commands.get_browser()
    forms = [ i for i in b._browser.forms() ]
    form = forms[0]
    assert len(form.controls) == 3, "you must have 'tidy' installed for this test to pass"

    # with a more correct form parser this would work like the above.
    commands.config('use_tidy', '0')
    commands.reload()
    forms = [ i for i in b._browser.forms() ]
    form = forms[0]
    assert len(form.controls) == 1
Esempio n. 19
0
def test_links_parsing():
    commands.config('use_tidy', '0')
    commands.go('/broken_linktext')
    commands.config('use_tidy', '1')
Esempio n. 20
0
def setup_module():
    config('require_tidy', 1)
Esempio n. 21
0
def teardown_module():
    config('require_tidy', 0)
Esempio n. 22
0
            print "Specified -n, will create a new history"
        new_history = True
    else:
        usage()

# state information
var_dir = os.path.join( os.path.expanduser('~'), ".check_galaxy", server )
if not os.access( var_dir, os.F_OK ):
    os.makedirs( var_dir, 0700 )

# default timeout for twill browser is never
socket.setdefaulttimeout(300)

# user-agent
tc.agent("Mozilla/5.0 (compatible; check_galaxy/0.1)")
tc.config('use_tidy', 0)


class Browser:
    def __init__(self):
        self.server = server
        self.tool = None
        self.tool_opts = None
        self._hda_id = None
        self._hda_state = None
        self._history_id = None
        self.check_file = None
        self.cookie_jar = os.path.join( var_dir, "cookie_jar" )
        dprint("cookie jar path: %s" % self.cookie_jar)
        if not os.access(self.cookie_jar, os.R_OK):
            dprint("no cookie jar at above path, creating")
Esempio n. 23
0
def test_links_parsing():
    commands.config('use_tidy', '0')
    commands.go('/broken_linktext')
    commands.follow('some text')
    commands.config('use_tidy', '1')
Esempio n. 24
0
def teardown_module():
    config('require_tidy', 0)
Esempio n. 25
0
lib_dir = os.path.join(scripts_dir, "..", "lib")
eggs_dir = os.path.join(scripts_dir, "..", "eggs",
                        "py%s-noplatform" % sys.version[:3])
sys.path.append(lib_dir)
sys.path.append(eggs_dir)
import pkg_resources
pkg_resources.require("twill")
import twill
import twill.commands as tc

# default timeout for twill browser is never
socket.setdefaulttimeout(300)

# user-agent
tc.agent("Mozilla/5.0 (compatible; check_galaxy/0.1)")
tc.config('use_tidy', 0)


class Browser:
    def __init__(self):
        self.server = server
        self.maint = maint
        self.tool = None
        self.tool_opts = None
        self.id = None
        self.status = None
        self.check_file = None
        self.hid = None
        self.cookie_jar = os.path.join(var_dir, "cookie_jar")
        dprint("cookie jar path: %s" % self.cookie_jar)
        if not os.access(self.cookie_jar, os.R_OK):
Esempio n. 26
0
def setup_module():
    config('require_tidy', 1)