Exemple #1
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"
def main():
    joker = SpawnKillerThread()
    try:
        SpawnDistributedCluster()
        print "Waiting for two JBoss instances to start up in cluster mode..."
        time.sleep(10)
        joker.start()
        #commands.debug('http', 1)
        #commands.debug('commands',1)
        b = get_browser()
        import socket
        myip = "http://" + socket.gethostbyname(socket.gethostname())
        b.go(myip + "/session-basket")
        b.submit(5)
        wordBatch = listOfRandomWords()
        for idx, w in enumerate(wordBatch):
            print "Adding word %d: '%s' to the list..." % (idx, w)
            commands.formvalue("1", "newItem:j_idt11", w)
            b.submit(4)
            commands.code(200)
            commands.find(w)
            time.sleep(0.25)
        print wordBatch, len(wordBatch)
        b.submit(5)
        commands.code(200)
        commands.reload()
        for w in wordBatch:
            commands.find(w)
    finally:
        joker.stopKilling = True
        joker.join()
        KillJBoss(0)
        KillJBoss(1)
def test_root_count(root):
    go("/")
    show()
    code(200)
    find("PyPI compatible package index serving 0 packages")
    showlinks()

    root.join("Twisted-11.0.0.tar.bz2").write("")
    reload()
    show()
    find("PyPI compatible package index serving 1 packages")
Exemple #4
0
def test_root_count(root):
    go("/")
    show()
    code(200)
    find("PyPI compatible package index serving 0 packages")
    showlinks()

    root.join("Twisted-11.0.0.tar.bz2").write("")
    reload()
    show()
    find("PyPI compatible package index serving 1 packages")
Exemple #5
0
 def attack(self):
     """ Attack the farm """
     print "Attack (" + self.x + "|" + self.y + "): ",
     if self.can_attack():
         commands.go(SERVER + 'build.php?tt=2&id=39')
         commands.fv('2', 'x', self.x)
         commands.fv('2', 'y', self.y)
         commands.fv('2', 'c', '4')
         for troop, num in self.troops.items():
             commands.fv('2', troop, num)
         commands.submit()
         commands.reload()
         html = commands.show()
         soup = BeautifulSoup(html)
         t = soup.find('div', {'class': 'in'}).text
         t = re.search('[0-9][0-9]?:[0-9]{2}:[0-9]{2}', t).group(0)
         h, m, s = [2 * int(e) for e in t.split(':')]
         wait = datetime.timedelta(seconds=s, minutes=m, hours=h)
         self.next_attack = datetime.datetime.now() + wait
         commands.fv('2', 's1', 'ok')
         commands.submit()
         print "done"
Exemple #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 = [ 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
 def attack(self):
     """ Attack the farm """
     print "Attack (" + self.x + "|" + self.y + "): ",
     if self.can_attack():
         commands.go(SERVER + 'build.php?tt=2&id=39')
         commands.fv('2', 'x', self.x)
         commands.fv('2', 'y', self.y)
         commands.fv('2', 'c', '4')
         for troop, num in self.troops.items():
             commands.fv('2', troop, num)
         commands.submit()
         commands.reload()
         html = commands.show()
         soup = BeautifulSoup(html)
         t = soup.find('div', {'class': 'in'}).text
         t = re.search('[0-9][0-9]?:[0-9]{2}:[0-9]{2}', t).group(0)
         h, m, s = [2 * int(e) for e in t.split(':')]
         wait = datetime.timedelta(seconds=s, minutes=m, hours=h)
         self.next_attack = datetime.datetime.now() + wait
         commands.fv('2', 's1', 'ok')
         commands.submit()
         print "done"