Login | Register
My pages Projects Community openCollabNet

Discussions > users > [maxq-users] Creating a simple text suite

maxq
Discussion topic

Back to topic list

[maxq-users] Creating a simple text suite

Author neves
Full name Paulo Eduardo Neves
Date 2005-03-29 08:13:39 PST
Message This is probably a newbie question, but I'm used to python unittest
module, but couldn't create a simple test suite adaoting the maxq
generated jython script.

I just want to have a fixture with some test methods, a test instance
should be created for each one, and setUp method must be called before
the execution. Would some kind soul here fix my test below to make the
testSuccess and testIncorrectPasswd methods run?

# Generated by MaxQ [com.bitmechanic.max​q.generator.JythonCo​deGenerator]
from PyHttpTestCase import PyHttpTestCase
from com.bitmechanic.maxq import Config
global validatorPkg
if __name__ == 'main':
    validatorPkg = Config.getValidatorPkgName()
# Determine the validator for this testcase.
exec 'from '+validatorPkg+' import Validator'


# definition of test class
class login_test(PyHttpTestCase):

    def setUp(self):
        self.msg('Test started')
        self.msg("Testing URL: %s" %
self.replaceURL('''http://localhost/tes​t/restricted'''))
        url = "http://localhost/tes​t/restricted"
        self.params = None
        Validator.validateRequest(self, self.getMethod(), "get", url,
self.params)
        self.get(url, self.params)
        self.msg("Response code: %s" % self.getResponseCode())
        self.assertEquals("Assert number 1 failed", 200, self.getResponseCode())
        Validator.validateRe​sponse(self, self.getMethod(), url, self.params)
        self.params = [
            ('''_gufauth_name''', '''username'''),
            ('''_gufauth_dest''', '''/test/restricted'''),]
        

    def testSuccess(self):
        self.params.append((​'''_gufauth_password​''', '''correct'''))

        #this is the url that makes the validation and set cookies
        url = "http://localhost/acl​_users/loginSuccess"
        Validator.validateRequest(self, self.getMethod(), "post", url,
self.params)
        self.post(url, self.params)
        self.msg("Response code: %s" % self.getResponseCode())
        self.assertEquals("Assert number 7 failed", 302, self.getResponseCode())
        Validator.validateRe​sponse(self, self.getMethod(), url, self.params)
        
        self.msg("Testing URL: %s" %
self.replaceURL('''http://localhost/tes​t/restricted'''))
        url = "http://localhost/tes​t/restricted"
        self.params = None
        Validator.validateRequest(self, self.getMethod(), "get", url,
self.params)
        self.get(url, self.params)
        self.msg("Response code: %s" % self.getResponseCode())
        self.assertEquals("Assert number 8 failed", 200, self.getResponseCode())
        Validator.validateRe​sponse(self, self.getMethod(), url, self.params)
        self.assertTrue("Sucess is in page content",
self.responseContain​s("sucess"))
        

    def testIncorrectPasswd(self):
        self.params.append((​'''_gufauth_password​''', '''incorrect'''))

        url = "http://localhost/acl​_users/loginSuccess"
        Validator.validateRequest(self, self.getMethod(), "post", url,
self.params)
        self.post(url, self.params)
        self.msg("Response code: %s" % self.getResponseCode())
        self.assertEquals("Assert number 7 failed", 302, self.getResponseCode())
        Validator.validateRe​sponse(self, self.getMethod(), url, self.params)
        
        self.msg("Testing URL: %s" %
self.replaceURL('''http://localhost/tes​t/restricted'''))
        url = "http://localhost/tes​t/restricted"
        self.params = None
        Validator.validateRequest(self, self.getMethod(), "get", url,
self.params)
        self.get(url, self.params)
        self.msg("Response code: %s" % self.getResponseCode())
        self.assertEquals("Assert number 8 failed", 200, self.getResponseCode())
        Validator.validateRe​sponse(self, self.getMethod(), url, self.params)
        self.assertFalse("Sucess is in page content",
self.responseContain​s("sucess"))


# Code to load and run the test
if __name__ == 'main':
    test = login_test("login_test")
    test.Run()


###############################

When I try to run this code, I get the error:
junit.framework.Asse​rtionFailedError:
junit.framework.Asse​rtionFailedError: Method "login_test" not found

thanks in advance for any help,


--
Paulo Eduardo Neves
Agenda do Samba & Choro
http://www.samba-choro.com.br

--------------------​--------------------​--------------------​---------
To unsubscribe, e-mail: users-unsubscribe@ma​xq.tigris.org
For additional commands, e-mail: users-help at maxq dot tigris dot org

« Previous message in topic | 1 of 1 | Next message in topic »

Messages

Show all messages in topic

[maxq-users] Creating a simple text suite neves Paulo Eduardo Neves 2005-03-29 08:13:39 PST
Messages per page: