def my_test(self):
	server_url = self.server_url
	self.get(server_url + "/past", description="View the past page")
	self.get(server_url + "/past", description="View the past page again")
	self.get(server_url, description='Get root URL')
	self.get(server_url + "/users/sign_up", description="View the user signup page")
	auth_token = extract_token(self.getBody(), 'name="authenticity_token" type="hidden" value="', '"')
	email = Lipsum().getUniqWord() + "@" + Lipsum().getWord() + ".com"
	name = Lipsum().getUniqWord()
	self.post(self.server_url + "/users",
		params=[['user[name]',name],
	    ['user[email]', email],
	      ['user[password]', 'alphabet'],
	      ['user[password_confirmation]', 'alphabet'],
	      ['authenticity_token', auth_token],
	      ['commit', 'Sign up']],
	    description="Create New User")
	

	#self.get(server_url + "/index", description="View the indexpage2")
	#auth_token = extract_token(self.getBody(), 'name="authenticity_token" type="hidden" value="', '"')
	self.get(server_url + "/new", description="View the past page2")
	auth_token = extract_token(self.getBody(), 'name="authenticity_token" type="hidden" value="', '"')

	self.post(self.server_url + "/parties",
	    params=[['party[name]', Lipsum().getUniqWord()],
	      ['party[owner]', name],
	      ['party[date]', '2014-12-03'],
	      ['party[time]', '17:00'],
	      ['party[location]',Lipsum().getUniqWord()],
	      ['party[description]',Lipsum().getUniqWord()],
	      ['authenticity_token', auth_token],
	      ['commit', 'Sign up']],
	    description="Create New party")
	self.get(server_url, description="back to indexpage")
    def accept_a_invite(self):
        
        server_url = self.server_url
        #This needs to be a created user
        user_mail='*****@*****.**'
        # If it is an autogenerated user this is the password
        password='******'
        
        print 'Goin to sign_in page'
        self.get(server_url + "/users/sign_in", description="Go to log in page")
        print 'on the page'
        auth_token = extract_token(self.getBody(), 'name="authenticity_token" type="hidden" value="', '"')
        print 'sending post now'
        self.post(self.server_url + "/users/sign_in",
            params=[['user[email]', user_mail],
              ['user[password]', password],
              ['authenticity_token', auth_token],
              ['commit', 'Log in']],
            description="Create New User")

        last_url = self.getLastUrl()
        user_id = last_url.split('/')[-1]
        print 'going to myinvites'
        self.get(server_url + "/myinvites", description="going to watch my invites")
        auth_token = extract_token(self.getBody(), 'name="authenticity_token" type="hidden" value="', '"')

        #the id of a party you have been invited to
        party_id =27

        print 'accepting a party invite'
        self.post(self.server_url + "/partyrequest/join",
                    params=[['party_id', party_id],['user_id',user_id],['authenticity_token', auth_token]],
                    description="Accetping the invite")

        print 'all done'
    def join_all_parties(self):

        server_url = self.server_url
        self.get(server_url, description='Get root URL')
        self.get(server_url + "/users/sign_up", description="View the user signup page")
        auth_token = extract_token(self.getBody(), 'name="authenticity_token" type="hidden" value="', '"')
        email = Lipsum().getUniqWord() + "@" + Lipsum().getWord() + ".com"
        name = Lipsum().getUniqWord()
        self.post(self.server_url + "/users",
                params=[['user[name]',name],
                ['user[email]', email],
                  ['user[password]', 'alphabet'],
                  ['user[password_confirmation]', 'alphabet'],
                  ['authenticity_token', auth_token],
                  ['commit', 'Sign up']],
                description="Create New User")

        last_url = self.getLastUrl()
        party_range=3
        user_id = last_url.split('/')[-1]
        self.get(server_url + "/index", description="watching parties to join")
        auth_token = extract_token(self.getBody(), 'name="authenticity_token" type="hidden" value="', '"')
        for i in range (1,party_range):
            self.post(self.server_url + "/join_members",
                    params=[['party_id', i],['user_id',user_id],['authenticity_token', auth_token]],

                    description="Joining party")
Exemplo n.º 4
0
    def test_create_comment(self):
        server_url = self.server_url
        self.get(server_url, description='View the homepage')
        project_url = random.choice(self.listHref(url_pattern='/projects/\d*'))
        self.logi(str(len(project_url)))
        self.get(server_url + project_url, description='View a project')
        leave_a_comment_url = self.listHref(url_pattern='/projects/\d+/comments/new',
                                            content_pattern='Leave a comment.*')
        comment_reply_urls = self.listHref(url_pattern='/projects/\d+/comments/new/\d+', content_pattern='Reply')
        comment_reply_url = random.choice(leave_a_comment_url + comment_reply_urls)
        self.get(server_url + comment_reply_url, description='Load new comment form')

        form_post_url = extract_token(self.getBody(),
                                      '<form accept-charset="UTF-8" action="',
                                      '"')

        comment_parent_id = None
        comment_start_string = '<input id="comment_parent_id" name="comment[parent_id]" type="hidden" value="'
        if self.getBody().find(comment_start_string) > -1:
            comment_parent_id = extract_token(self.getBody(), comment_start_string, '"')
        params = self.makeParams()
        params += [['comment[text]', Lipsum().getParagraph(length=16)]]
        if comment_parent_id:
            params += [['comment[parent_id]', comment_parent_id]]
        self.post(server_url + form_post_url, params=params, description='Post a new comment')
    def accept_all_invites(self):
        server_url = self.server_url

        #This needs to be a created user
        user_mail='*****@*****.**'
        # If it is an autogenerated user this is the password
        password='******'

        
        self.get(server_url + "/users/sign_in", description="Go to log in page")
        auth_token = extract_token(self.getBody(), 'name="authenticity_token" type="hidden" value="', '"')
        self.post(self.server_url + "/users/sign_in",
            params=[['user[email]', user_mail],
              ['user[password]', password],
              ['authenticity_token', auth_token],
              ['commit', 'Log in']],
            description="Create New User")

        last_url = self.getLastUrl()
        user_id = last_url.split('/')[-1]

        self.get(server_url + "/myinvites", description="going to watch my invites")
        auth_token = extract_token(self.getBody(), 'name="authenticity_token" type="hidden" value="', '"')

        party_range=16
        
        for i in range (1,party_range):
            self.post(self.server_url + "/partyrequest/join",
                    params=[['party_id', i],['user_id',user_id],['authenticity_token', auth_token]],
                      
                    description="Joining party")
    def test_critical_path(self):
	server_url = self.server_url
	self.get(server_url, description='Get root URL')
	self.get(server_url + "/users/sign_up", description="View the user signup page")

	auth_token = extract_token(self.getBody(), 'name="authenticity_token" type="hidden" value="', '"')
	email = Lipsum().getUniqWord() + "@" + Lipsum().getWord() + ".com"

	self.post(self.server_url + "/users",
	    params=[['user[email]', email],
	      ['user[password]', 'alphabet'],
	      ['user[password_confirmation]', 'alphabet'],
	      ['authenticity_token', auth_token],
	      ['commit', 'Sign up']],
	    description="Create New User")

	self.get(server_url + "/communities/new", description="View the new communities page")
	auth_token = extract_token(self.getBody(), 'name="authenticity_token" type="hidden" value="', '"')

	community_name = Lipsum().getSentence()
	self.post(self.server_url + "/communities",
	    params=[['community[name]', community_name],
	      ['authenticity_token', auth_token],
	      ['commit', 'Create Community']],
	    description="Create New Community")
	last_url = self.getLastUrl()

	created_community_id = last_url.split('/')[-1]
	self.get(server_url + "/communities/"+created_community_id, description="View the created community page")

	self.get(server_url + "/submissions/new", description="View the new submissions page")
	auth_token = extract_token(self.getBody(), 'name="authenticity_token" type="hidden" value="', '"')

	submission_title = Lipsum().getSentence()
	submission_url = "http://www."+Lipsum().getWord() + Lipsum().getUniqWord() + ".com/"
	self.post(self.server_url + "/submissions",
	    params=[['submission[title]', submission_title],
	      ['submission[url]', submission_url],
	      ['submission[community_id]', created_community_id],
	      ['authenticity_token', auth_token],
	      ['commit', 'Create Submission']],
	    description="Create New Submission")
	
	last_url = self.getLastUrl()
	created_submission_id = last_url.split('/')[-1]

	self.get(server_url + "/comments/new", description="View the new comments page")
	auth_token = extract_token(self.getBody(), 'name="authenticity_token" type="hidden" value="', '"')

	comment_message = Lipsum().getSentence()
	comment_parent = ''
	submission_id = created_submission_id
	self.post(self.server_url + "/comments",
	    params=[['comment[message]', comment_message],
	      ['comment[submission_id]', submission_id],
	      ['comment[parent_id]', comment_parent],
	      ['authenticity_token', auth_token],
	      ['commit', 'Create Comment']],
	    description="Create New Comment")
    def test_critical_path(self):
	server_url = self.server_url
	self.get(server_url, description='Get root URL')
	self.get(server_url + "/users/sign_up", description="View the user signup page")

	auth_token = extract_token(self.getBody(), 'name="authenticity_token" type="hidden" value="', '"')
	email = Lipsum().getUniqWord() + "@" + Lipsum().getWord() + ".com"

	self.post(self.server_url + "/users",
	    params=[['user[email]', email],
	      ['user[password]', 'alphabet'],
	      ['user[password_confirmation]', 'alphabet'],
	      ['authenticity_token', auth_token],
	      ['commit', 'Sign up']],
	    description="Create New User")

	self.get(server_url + "/challenges/new", description="View the new challenges page")
	auth_token = extract_token(self.getBody(), 'name="authenticity_token" type="hidden" value="', '"')

	challenge_name = Lipsum().getSentence()
	self.post(self.server_url + "/challenges",
	    params=[['challenge[name]', challenge_name],
	      ['authenticity_token', auth_token],
	      ['commit', 'Create challenge']],
	    description="Create New challenge")
	last_url = self.getLastUrl()

	created_challenge_id = last_url.split('/')[-1]
	self.get(server_url + "/challenges/"+created_challenge_id, description="View the created challenge page")

	self.get(server_url + "/progresses/new", description="View the new progresses page")
	auth_token = extract_token(self.getBody(), 'name="authenticity_token" type="hidden" value="', '"')

	progress_title = Lipsum().getSentence()
	progress_url = "http://www."+Lipsum().getWord() + Lipsum().getUniqWord() + ".com/"
	self.post(self.server_url + "/progresses",
	    params=[['progress[title]', progress_title],
	      ['progress[url]', progress_url],
	      ['progress[challenge_id]', created_challenge_id],
	      ['authenticity_token', auth_token],
	      ['commit', 'Create progress']],
	    description="Create New progress")
	last_url = self.getLastUrl()
	created_progress_id = last_url.split('/')[-1]

	self.get(server_url + "/comments/new", description="View the new comments page")
	auth_token = extract_token(self.getBody(), 'name="authenticity_token" type="hidden" value="', '"')

	comment_message = Lipsum().getSentence()
	comment_parent = ''
	progress_id = created_progress_id
	self.post(self.server_url + "/comments",
	    params=[['comment[message]', comment_message],
	      ['comment[progress_id]', progress_id],
	      ['comment[parent_id]', comment_parent],
	      ['authenticity_token', auth_token],
	      ['commit', 'Create Comment']],
	    description="Create New Comment")
Exemplo n.º 8
0
    def test_critical_path(self):
        server_url = self.server_url

        # create a new user
        self.get(server_url + "/users/sign_up", description="View the user signup page")
        auth_token = extract_token(self.getBody(), 'name="authenticity_token" type="hidden" value="', '"')
        email = Lipsum().getUniqWord() + "@" + Lipsum().getWord() + ".com"
        first_name = Lipsum().getWord()
        last_name = Lipsum().getWord()
        self.post(self.server_url + "/users",
                  params=[['user[email]', email],
                          ['user[first_name]', first_name],
                          ['user[last_name]', last_name],
                          ['user[password]', 'alphabet'],
                          ['user[password_confirmation]', 'alphabet'],
                          ['authenticity_token', auth_token],
                          ['commit', 'Sign up']],
                  description="Create New User")

        # create a new suppr
        self.get(server_url + "/dinners/new", description="Create a new suppr")
        auth_token = extract_token(self.getBody(), 'name="authenticity_token" type="hidden" value="', '"')
        suppr_title = Lipsum().getSentence()
        suppr_date = datetime.date.today() + datetime.timedelta(days=randint(0,365*10))
        suppr_location = Lipsum().getSentence()
        suppr_description = Lipsum().getSentence()
        suppr_category = "Italian"
        suppr_price = 26
        suppr_seats = 30
        # FIXME: suppr_image ....
        self.post(self.server_url + "/dinners",
                  params=[['dinner[title]', suppr_title],
                          ['dinner[date]', suppr_date],
                          ['dinner[location]', suppr_location],
                          ['dinner[description]', suppr_description],
                          ['dinner[price]', suppr_price],
                          ['dinner[category]', suppr_category],
                          ['dinner[seats]', suppr_seats],
                          ['authenticity_token', auth_token],
                          ['commit', 'Create Dinner']],
                  description="Create New Suppr")
        
        last_url = self.getLastUrl()
        created_suppr_id = last_url.split('/')[-1]
        
        self.get(server_url + "/dinners/join/"+created_suppr_id, description="View the created Suppr page")

        # add a comments
        self.get(server_url + "/dinners/"+created_suppr_id, description="View the created Suppr page")
        auth_token = extract_token(self.getBody(), 'name="authenticity_token" type="hidden" value="', '"')
        comment_content = Lipsum().getSentence()
        comment_suppr_id = extract_token(self.getBody(), 'id="comment_dinner_id" name="comment[dinner_id]" type="hidden" value="', '"')
        self.post(self.server_url + "/comments",
                  params=[['comment[content]', comment_content],
                          ['comment[dinner_id]', comment_suppr_id],
                          ['authenticity_token', auth_token],
                          ['commit', 'Create Comment']],
                  description="Create New Comment")
Exemplo n.º 9
0
    def test_download_upload(self):
        server_url = self.server_url
        # /tmp/tmpswgrBv_funkload/watch0003.request
        self.get(server_url + "/account/login/",
            description="Get /account/login/")
        user = '******'
        password = '******'
        csrftoken = extract_token(self.getBody(),'name=\'csrfmiddlewaretoken\' value=\'','\'')
        print "%s\n"%csrftoken
        self.post(server_url + "/account/login/", params=[
            ['csrfmiddlewaretoken',csrftoken],
            ['username', user],
            ['password', password]],description="login")

        # /tmp/tmpswgrBv_funkload/watch0006.request
        self.get(server_url + "/submit/download",
            description="Get /submit/download")
        # /tmp/tmpswgrBv_funkload/watch0007.request
        self.get(server_url + "/submit/2/",
            description="Get /submit/2/")
        # /tmp/tmpswgrBv_funkload/watch0008.request
        
        self.get(server_url+"/user/input/battleships.in",
            description="Get battleships.in")
        # /tmp/tmpswgrBv_funkload/watch0009.request
        self.post(server_url + "/submit/2/", params=[
            ['sourcecode', Upload("foobaz.in")],
            ['output_file', Upload("foobaz.in")]],
            description="Post /submit/2/")
    def test_editProfile_user(self):
		#my_test()
		server_url = self.server_url
		self.get(server_url, description='Get root URL')
		
		self.get(server_url + "/users/sign_up", description="View the user signup page")
		auth_token = extract_token(self.getBody(), 'name="authenticity_token" type="hidden" value="', '"')
		
		email = Lipsum().getUniqWord() + "@" + Lipsum().getWord() + ".com"
		username = Lipsum().getUniqWord();

		self.post(self.server_url + "/users",
			params=[['user[name]',username],
		    ['user[email]', email],
		      ['user[password]', 'alphabet'],
		      ['user[password_confirmation]', 'alphabet'],
		      ['authenticity_token', auth_token],
		      ['commit', 'Sign up']],
		    description="Create New User")
		# end my_test()
		# start edit profile

		#myID = "number that i will get from code"
		
		#user_id = last_url.split('/')[-1]
		
		self.get(server_url + "/profiles/" + user_id +"/edit", description="View the edit profile page")
Exemplo n.º 11
0
    def test_download_upload(self):
        server_url = self.server_url
        # /tmp/tmpswgrBv_funkload/watch0003.request
        self.get(server_url + "/account/login/",
                 description="Get /account/login/")
        user = '******'
        password = '******'
        csrftoken = extract_token(self.getBody(),
                                  'name=\'csrfmiddlewaretoken\' value=\'',
                                  '\'')
        print "%s\n" % csrftoken
        self.post(server_url + "/account/login/",
                  params=[['csrfmiddlewaretoken', csrftoken],
                          ['username', user], ['password', password]],
                  description="login")

        # /tmp/tmpswgrBv_funkload/watch0006.request
        self.get(server_url + "/submit/download",
                 description="Get /submit/download")
        # /tmp/tmpswgrBv_funkload/watch0007.request
        self.get(server_url + "/submit/2/", description="Get /submit/2/")
        # /tmp/tmpswgrBv_funkload/watch0008.request

        self.get(server_url + "/user/input/battleships.in",
                 description="Get battleships.in")
        # /tmp/tmpswgrBv_funkload/watch0009.request
        self.post(server_url + "/submit/2/",
                  params=[['sourcecode', Upload("foobaz.in")],
                          ['output_file', Upload("foobaz.in")]],
                  description="Post /submit/2/")
Exemplo n.º 12
0
    def test_register(self):
        self.logout()

        num_users = self.conf_getInt('test_register', 'num_users')
        for i in range(num_users):
            username = self.lipsum.getUniqWord()
            password = self.lipsum.getWord()
            name = self.lipsum.getWord() + " " + self.lipsum.getWord()
            email = self.lipsum.getWord() + "@example.org"

            server_url = self.server_url

            csrftoken = extract_token(self.getBody(), "name='csrfmiddlewaretoken' value='", "' />")
            self.post(server_url + "/register",
                params=[ ['csrfmiddlewaretoken', csrftoken],
                ['username', username],
                ['password1', password],
                ['password2', password],
                ['name', name],
                ['email', email],
                ['profiletype', '1']],
                description="Post /register")

            self.assert_("index" in self.getLastUrl(), "Error in registration")
            self.logout()
Exemplo n.º 13
0
    def test_signup_path(self):
        server_url = self.server_url
        # Get homepage
        self.get(server_url, description="View the home page")


        # Fill out manual signup form
        auth_token = extract_token(self.getBody(), 'name="authenticity_token" type="hidden" value="', '"')
        email = Lipsum().getUniqWord() + "@" + Lipsum().getWord() + ".com"
        username = Lipsum().getUniqWord()

        self.addMetadata(**{'auth_token': auth_token})

        for x in range(0, 3):
            self.get(self.server_url + '/users/check_username.json',
                     params=[['username', Lipsum().getWord()]],
                     description='Check username availability')
            self.get(self.server_url + '/users/check_email.json',
                     params=[['username', Lipsum().getWord() + "@" + Lipsum().getWord()]],
                     description='Check email availability')
            self.get(self.server_url + '/users/check_password.json',
                     params=[['username', Lipsum().getWord()]],
                     description='Check password availability')

        self.post(self.server_url + "/users",
                  params=[['user[email]', email],
                          ['user[password]', 'alphabet'],
                          ['user[password_confirmation]', 'alphabet'],
                          ['user[username]', username],
                          ['authenticity_token', auth_token],
                          ['commit', 'Sign up']],
                  description="Create New User")
        self.get(self.server_url, description="View the homepage after signup")
Exemplo n.º 14
0
    def test_register(self):
        self.logout()

        num_users = self.conf_getInt('test_register', 'num_users')
        for i in range(num_users):
            username = self.lipsum.getUniqWord()
            password = self.lipsum.getWord()
            name = self.lipsum.getWord() + " " + self.lipsum.getWord()
            email = self.lipsum.getWord() + "@example.org"

            server_url = self.server_url

            csrftoken = extract_token(self.getBody(), "name='csrfmiddlewaretoken' value='", "' />")
            self.post(server_url + "/register",
                params=[ ['csrfmiddlewaretoken', csrftoken],
                ['username', username],
                ['password1', password],
                ['password2', password],
                ['name', name],
                ['email', email],
                ['affiliation', 'MIT']],
                description="Post /register")
        
            self.assert_("index" in self.getLastUrl(), "Error in registration")
            self.logout()
    def create_and_delete_party(self):
		self.logd( "message")
		server_url = self.server_url
		self.get(server_url + "/past", description="View the past page")
		self.get(server_url + "/past", description="View the past page again")
		self.get(server_url, description='Get root URL')
		self.get(server_url + "/users/sign_up", description="View the user signup page")
		auth_token = extract_token(self.getBody(), 'name="authenticity_token" type="hidden" value="', '"')
		email = Lipsum().getUniqWord() + "@" + Lipsum().getWord() + ".com"
		name = Lipsum().getUniqWord()
		self.post(self.server_url + "/users",
			params=[['user[name]',name],
		    ['user[email]', email],
		      ['user[password]', 'alphabet'],
		      ['user[password_confirmation]', 'alphabet'],
		      ['authenticity_token', auth_token],
		      ['commit', 'Sign up']],
		    description="Create New User")


		#self.get(server_url + "/index", description="View the indexpage2")
		#auth_token = extract_token(self.getBody(), 'name="authenticity_token" type="hidden" value="', '"')
		self.get(server_url + "/new", description="create party page")
		auth_token = extract_token(self.getBody(), 'name="authenticity_token" type="hidden" value="', '"')

		self.post(self.server_url + "/parties",
		    params=[['party[name]', Lipsum().getUniqWord()],
		      ['party[owner]', name],
		      ['party[date]', '2016-12-03'],
		      ['party[time]', '17:00'],
		      ['party[location]',Lipsum().getUniqWord()],
		      ['party[description]',Lipsum().getUniqWord()],
		      ['authenticity_token', auth_token],
		      ['commit', 'Sign up']],
		    description="Create New party")

		last_url = self.getLastUrl()

		created_party_id = last_url.split('/')[-1]

		self.get(server_url + "/myparties", description="Going to my parties page")
		auth_token = extract_token(self.getBody(), 'name="authenticity_token" type="hidden" value="', '"')


		self.delete(self.server_url + '/parties/'+created_party_id, description="Delete the party",)
		self.get(server_url + "/", description="Back to index page")
    def invite_a_user(self):
       	server_url = self.server_url
    	self.get(server_url, description='Get root URL')
    	self.get(server_url + "/users/sign_up", description="View the user signup page")
    	auth_token = extract_token(self.getBody(), 'name="authenticity_token" type="hidden" value="', '"')
    	email = Lipsum().getUniqWord() + "@" + Lipsum().getWord() + ".com"
    	name = Lipsum().getUniqWord()
    	self.post(self.server_url + "/users",
    			params=[['user[name]',name],
    		    ['user[email]', email],
    		      ['user[password]', 'alphabet'],
    		      ['user[password_confirmation]', 'alphabet'],
    		      ['authenticity_token', auth_token],
    		      ['commit', 'Sign up']],
    		    description="Create New User")


    		#self.get(server_url + "/index", description="View the indexpage2")
    		#auth_token = extract_token(self.getBody(), 'name="authenticity_token" type="hidden" value="', '"')
    	self.get(server_url + "/new", description="create party page")
    	auth_token = extract_token(self.getBody(), 'name="authenticity_token" type="hidden" value="', '"')

    	self.post(self.server_url + "/parties",
    		    params=[['party[name]', Lipsum().getUniqWord()],
    		      ['party[owner]', name],
    		      ['party[date]', '2016-12-03'],
    		      ['party[time]', '17:00'],
    		      ['party[location]',Lipsum().getUniqWord()],
    		      ['party[description]',Lipsum().getUniqWord()],
    		      ['authenticity_token', auth_token],
    		      ['commit', 'Sign up']],
    		    description="Create New party")

    	last_url = self.getLastUrl()

    	created_party_id = last_url.split('/')[-1]

        userid=4


    	self.post(self.server_url + "/createasinvite/",
    		    params=[['party_id', created_party_id],['user_id',userid],['authenticity_token',auth_token]],

    		    description="Create New party")
  def my_test(self):
      server_url = self.server_url
      self.get(server_url + "/past", description="View the past page")
      self.get(server_url, description='Get root URL')
      self.get(server_url + "/users/sign_up", description="View the user signup page")
      auth_token = extract_token(self.getBody(), 'name="authenticity_token" type="hidden" value="', '"')
      email = Lipsum().getUniqWord() + "@" + Lipsum().getWord() + ".com"

      self.post(self.server_url + "/users",
        params=[['user[name]',Lipsum().getUniqWord()],
          ['user[email]', email],
            ['user[password]', 'alphabet'],
            ['user[password_confirmation]', 'alphabet'],
            ['authenticity_token', auth_token],
            ['commit', 'Sign up']],
          description="Create New User")

      self.get(server_url + "/index", description="View the indexpage2")
      auth_token = extract_token(self.getBody(), 'name="authenticity_token" type="hidden" value="', '"')
    def test_create_party(self):
		#my_test()
		server_url = self.server_url
		self.get(server_url, description='Get root URL')
		
		self.get(server_url + "/users/sign_up", description="View the user signup page")
		auth_token = extract_token(self.getBody(), 'name="authenticity_token" type="hidden" value="', '"')
		
		email = Lipsum().getUniqWord() + "@" + Lipsum().getWord() + ".com"
		username = Lipsum().getUniqWord();

		self.post(self.server_url + "/users",
			params=[['user[name]',username],
		    ['user[email]', email],
		      ['user[password]', 'alphabet'],
		      ['user[password_confirmation]', 'alphabet'],
		      ['authenticity_token', auth_token],
		      ['commit', 'Sign up']],
		    description="Create New User")
		# end my_test()
		# start create party
		self.get(server_url + "/new", description="View the host party page") # dont now if i need this yet
		auth_token = extract_token(self.getBody(), 'name="authenticity_token" type="hidden" value="', '"')
	
		partyname = Lipsum().getUniqWord()
		#username = Lipsum().getUniqWord();
		dummyDate = "03/12/2015"
		dummyTime = "22:17"
		dummyLocation = "Del playa drive 6761"
		dummyDecription = "Best party ever"

		self.post(self.server_url + "/parties",
		params=[['party[name]',partyname],
	    ['party[owner]', username],
	      ['party[date]', '03/12/2015'], #'2016-12-03'
	      ['party[time]', '22:17'],
	      ['party[location]', dummyLocation],
	      ['party[description]', dummyDecription],
	      ['authenticity_token', auth_token],
	      ['commit', 'Create Party']], # ['commit', 'Create Party']]
	    description="username created a New Party")
		self.get(server_url, description="back to indexpage")
 def create_a_close_parties(self):
     print 'begin'
     #creates many parties close to UCSB
     server_url = self.server_url
     self.get(server_url + "/users/sign_up", description="View the user signup page")
     auth_token = extract_token(self.getBody(), 'name="authenticity_token" type="hidden" value="', '"')
     email = Lipsum().getUniqWord() + "@" + Lipsum().getWord() + ".com"
     name = Lipsum().getUniqWord()
     print 'create a user'
     self.post(self.server_url + "/users",
             params=[['user[name]',name],
             ['user[email]', email],
               ['user[password]', 'alphabet'],
               ['user[password_confirmation]', 'alphabet'],
               ['authenticity_token', auth_token],
               ['commit', 'Sign up']],
             description="Create New User")
     print 'go to party page '
     self.get(server_url + "/new", description="create party page")
     auth_token = extract_token(self.getBody(), 'name="authenticity_token" type="hidden" value="', '"')
    
     rand = random.random()
     
     ran=rand/10
     
     lat=34.42
         
     lon=-119.9+ran
     print 'posting a party'
     self.post(self.server_url + "/parties",
         params=[['party[name]', Lipsum().getUniqWord()],
           ['party[owner]', name],
           ['party[date]', '2016-12-03'],
           ['party[time]', '17:00'],
           ['party[location]',''+str(lat)+', -'+str(lon)],
           ['party[latitude]',lat],
           ['party[longitude]',lon],
           ['party[description]',Lipsum().getUniqWord()],
           ['authenticity_token', auth_token],
           ['commit', 'Sign up']],
         description="Create New party")
     print 'all done'
Exemplo n.º 20
0
    def test_simple(self):
        server_url = self.server_url
        reply = self.get(server_url + '/auth/login',
                         description='GET /auth/login')
        csrftoken = extract_token(self.getBody(),
                                  'name="csrf_token" type="hidden" value="',
                                  '">').strip()
        self.post(server_url + '/auth/login',
                  params=[['csrf_token', csrftoken], ['username', '123'],
                          ['password', '123']],
                  description='POST /auth/login')

        reply = self.get(server_url + '/album/search',
                         description='GET /album/search')
        csrftoken = extract_token(self.getBody(),
                                  'name="csrf_token" type="hidden" value="',
                                  '">').strip()
        self.post(server_url + '/album/search',
                  params=[['csrf_token', csrftoken], ['tags', 'europe']],
                  description='POST /album/search')
    def create_many_parties(self):
        server_url = self.server_url
       
        #This needs to be a created user
        user_mail='*****@*****.**'
        username='******'
        # If it is an autogenerated user this is the password
        password='******'
        
        print 'Goin to sign_in page'
        self.get(server_url + "/users/sign_in", description="Go to log in page")
        print 'on the page'
        auth_token = extract_token(self.getBody(), 'name="authenticity_token" type="hidden" value="', '"')
        print 'sending post now'
        self.post(self.server_url + "/users/sign_in",
            params=[['user[email]', user_mail],
              ['user[password]', password],
              ['authenticity_token', auth_token],
              ['commit', 'Log in']],
            description="Create New User")
        

        #self.get(server_url + "/index", description="View the indexpage2")
        #auth_token = extract_token(self.getBody(), 'name="authenticity_token" type="hidden" value="', '"')
        self.get(server_url + "/new", description="create party page")
        auth_token = extract_token(self.getBody(), 'name="authenticity_token" type="hidden" value="', '"')
        party_amount=10

        for i in range (party_amount):
            print 'making the party'

            self.post(self.server_url + "/parties",
                params=[['party[name]', Lipsum().getUniqWord()],
                  ['party[owner]', username],
                  ['party[date]', '2016-12-03'],
                  ['party[time]', '17:00'],
                  ['party[location]',Lipsum().getUniqWord()],
                  ['party[description]',Lipsum().getUniqWord()],
                  ['authenticity_token', auth_token],
                  ['commit', 'Sign up']],
                description="Create New party")
Exemplo n.º 22
0
    def login(self, page="/index"):
        # The description should be set in the configuration file
        server_url = self.server_url

        reply = self.get(server_url + "/index", description="Get index")

        csrftoken = extract_token(self.getBody(),
                                  "name='csrfmiddlewaretoken' value='", "' />")
        self.post(server_url + "/accounts/login/?next=" + page,
                  params=[['csrfmiddlewaretoken', csrftoken],
                          ['redirect_to', page], ['username', self.username],
                          ['password', self.pwd]],
                  description="Post /accounts/login/")
Exemplo n.º 23
0
 def test_video_upload(self):
     server_url = self.server_url
     self.test_user_login()
     self.get(server_url + "/videos/new", description="View the user signin page")
     auth_token = extract_token(self.getBody(), 'name="authenticity_token" type="hidden" value="', '"')
     nb_time = self.conf_getInt("test_video_upload", 'nb_time')
     for i in range(nb_time):
         self.post(server_url + "/videos",
             params=[['authenticity_token', auth_token],
                     ['video[category]', Lipsum().getWord()],
                     ['video[local_videofile]',  Upload("./vids/1.mp4")],
                     ['video[title]', Lipsum().getWord()]],
                     description = "upload video"
                 )
Exemplo n.º 24
0
    def login(self, page="/index"):
        # The description should be set in the configuration file
        server_url = self.server_url

        reply = self.get(server_url + "/index",
            description="Get index")

        csrftoken = extract_token(self.getBody(), "name='csrfmiddlewaretoken' value='", "' />")
        self.post(server_url + "/accounts/login/?next=" + page,
            params=[['csrfmiddlewaretoken', csrftoken],
            ['redirect_to', page],
            ['username', self.username],
            ['password', self.pwd]],
            description="Post /accounts/login/")
Exemplo n.º 25
0
    def test_user_login(self):
        server_url = self.server_url
        self.get(server_url, description='Get root URL')
        self.get(server_url + "/users/sign_in", description="View the user signin page")

        auth_token = extract_token(self.getBody(), 'name="authenticity_token" type="hidden" value="', '"')
        email = "*****@*****.**"
        password = "******"

        self.post(self.server_url + "/users/sign_in",
            params=[['user[email]', email],
            ['user[password]', password],
            ['authenticity_token', auth_token],
            ['commit', 'Sign in']],
            description="Login") 
Exemplo n.º 26
0
    def test_submit_paper(self):
        page = "/submit"
        self.login(page)
        self.assert_(page == self.getLastUrl(), "Error in login")

        num_papers = self.conf_getInt('test_submit_paper', 'num_papers')
        for i in range(num_papers):
            csrftoken = extract_token(self.getBody(), "name='csrfmiddlewaretoken' value='", "' />")
            self.post(self.server_url + "/submit",
                params=[['csrfmiddlewaretoken', csrftoken],
                ['coauthors[]', self.lipsum.getWord()],
                ['coauthors[]', self.lipsum.getWord()], 
                ['title', self.lipsum.getSentence()],
                ['contents', Upload('files/rms_crossstitch.pdf')],
                ['abstract', self.lipsum.getMessage()]],
                description="Post /accounts/login/")
            self.assert_("paper" in self.getLastUrl(), "Error in login")
Exemplo n.º 27
0
    def test_register(self):
        username = self.lipsum.getUniqWord()
        password = self.lipsum.getWord()
        name = self.lipsum.getWord() + " " + self.lipsum.getWord()
        email = self.lipsum.getWord() + "@example.org"

        server_url = self.server_url
        # self.get(server_url + "/register", description='Get url')

        csrftoken = extract_token(self.getBody(),
                                  "name='csrfmiddlewaretoken' value='", "' />")
        self.post(server_url + "/register",
                  params=[['csrfmiddlewaretoken', csrftoken],
                          ['username', username], ['password1', password],
                          ['password2', password], ['name', name],
                          ['email', email], ['profiletype', '1']],
                  description="Post /register")
    def test_critical_path_readonly(self):
		server_url = self.server_url
		self.get(server_url, description='View root URL')
		self.get(server_url + "/users/sign_up", description="View the user signup page")
	
		auth_token= extract_token(self.getBody(), 'name="authenticity_token" type="hidden" value"','"')
		email=Lipsum().getUniqWord+"@"+Lipsum().getWord()+".com"
		name =Lipsum().getUniqWord

		self.post(self.server_url +"/users",
			params=[['user[name]', name],
			['user[email]', email],
			['user[password]', 'alphabet'],
			['user[password_confirmation]', auth_token],
			['commit','Sign up']],
			description="Create New User")

		self.get(server_url + "/challenges/", description="View the challenges page")
Exemplo n.º 29
0
    def test_register(self):
        username = self.lipsum.getUniqWord()
        password = self.lipsum.getWord()
        name = self.lipsum.getWord() + " " + self.lipsum.getWord()
        email = self.lipsum.getWord() + "@example.org"

        server_url = self.server_url
        # self.get(server_url + "/register", description='Get url')

        csrftoken = extract_token(self.getBody(), "name='csrfmiddlewaretoken' value='", "' />")
        self.post(server_url + "/register",
            params=[ ['csrfmiddlewaretoken', csrftoken],
            ['username', username],
            ['password1', password],
            ['password2', password],
            ['name', name],
            ['email', email],
            ['profiletype', '1']],
            description="Post /register")
Exemplo n.º 30
0
    def test_submit_paper(self):
        page = "/submit"
        self.login(page)
        self.assert_(page == self.getLastUrl(), "Error in login")

        num_papers = self.conf_getInt('test_submit_paper', 'num_papers')
        for i in range(num_papers):
            csrftoken = extract_token(self.getBody(),
                                      "name='csrfmiddlewaretoken' value='",
                                      "' />")
            self.post(
                self.server_url + "/submit",
                params=[['csrfmiddlewaretoken', csrftoken],
                        ['coauthors[]', self.lipsum.getWord()],
                        ['coauthors[]', self.lipsum.getWord()],
                        ['title', self.lipsum.getSentence()],
                        ['contents',
                         Upload('files/rms_crossstitch.pdf')],
                        ['abstract', self.lipsum.getMessage()]],
                description="Post /accounts/login/")
            self.assert_("paper" in self.getLastUrl(), "Error in login")
Exemplo n.º 31
0
    def test_random_register(self):
        self.logout()

        username = self.lipsum.getUniqWord()
        password = self.lipsum.getUniqWord()

        server_url = self.server_url
        # self.get(server_url + "/register", description='Get url')

        csrftoken = extract_token(self.getBody(),
                                  "name='csrfmiddlewaretoken' value='", "' />")
        self.post(server_url + "/register",
                  params=[['csrfmiddlewaretoken', csrftoken],
                          ['username', username], ['password1', password],
                          ['password2', password], ['name', 'New User'],
                          ['email', '*****@*****.**'],
                          ['profiletype', '1']],
                  description="Post /register")

        # TODO: Check page after logging in.
        self.logout()
        self.login_as(username, password)
        self.logout()
Exemplo n.º 32
0
    def test_random_register(self):
        self.logout()

        username = self.lipsum.getUniqWord()
        password = self.lipsum.getUniqWord()

        server_url = self.server_url
        # self.get(server_url + "/register", description='Get url')

        csrftoken = extract_token(self.getBody(), "name='csrfmiddlewaretoken' value='", "' />")
        self.post(server_url + "/register",
            params=[ ['csrfmiddlewaretoken', csrftoken],
            ['username', username],
            ['password1', password],
            ['password2', password],
            ['name', 'New User'],
            ['email', '*****@*****.**'],
            ['profiletype', '1']],
            description="Post /register")

        # TODO: Check page after logging in.
        self.logout()
        self.login_as(username, password)
        self.logout()
    def test_critical_path(self):
        
        server_url = self.server_url
        
        self.get(server_url, description='Get root url')

        # Test user sign-up
        self.get(server_url + "/signup", description="Get sign-up url")
        
        auth_token = extract_token(self.getBody(), 'name="authenticity_token" type="hidden" value="', '"')
        name = Lipsum().getUniqWord(length_min=1, length_max=20)
        maxLenMail = 30 - len(name)
        email = name + "@" + Lipsum().getUniqWord(length_min=1, length_max=maxLenMail) + ".com"
        password = hash(email)

        self.post(self.server_url + "/users",
        params=[ ['user[name]', name],
          ['user[email]', email],
          ['user[password]', password],
          ['user[password_confirmation]', password],
          ['authenticity_token', auth_token],
          ['commit', 'Create my account']],
        description="Create New User")
 
        # Check if signing up succeeds
        self.assertEquals(self.getLastUrl(), "/profile", "Is not user profile page")
        self.assert_(name in self.getBody(), "Wrong profile page")

        # Test quest creation
        self.get(server_url + "/quests/new", description="Get new-quest page")

        auth_token_quest = extract_token(self.getBody(), 'name="authenticity_token" type="hidden" value="', '"')
        title = Lipsum().getSubject(uniq=True)
        description = Lipsum().getMessage()
        source = Lipsum().getAddress()
        destination = Lipsum().getAddress()
        reward = randint(1, 10000)

        self.post(self.server_url + "/quests",
        params=[ ['quest[title]', title],
          ['quest[description]', description],
          ['quest[source]', source],
          ['quest[destination]', destination],
          ['quest[reward]', reward],
          ['authenticity_token', auth_token_quest],
          ['commit', 'Create Quest']], 
        description="Create New Quest")

        # Check if quest creation succeeds
        self.assertEquals(self.getLastUrl(), "/profile", "Is not user profile page")
        self.assert_(name in self.getBody(), "Wrong profile page")
        user_id = extract_token(self.getBody(), 'User ID : ', ' ')
        user_id = str(int(user_id))
        

#         # Test quest searching page
#         self.get(server_url + "/quests", description="Get quests url")
#         self.assert_("Quests" in self.getBody(), "Wrong quest page")
#         self.assert_("Advanced Search" in self.getBody(), "Wrong quest page")
#         self.assert_("Search in title" in self.getBody(), "Wrong quest page")
# 
#         # Test sorting (only on foreign key)
#         sorted_url = server_url + "/quests?direction=asc&sort=quest_giver_id"
#         self.get(sorted_url, description="Sort by quest giver")
#         test_arrow_up = 'Quest Giver <img alt="Arrow up"'
#         self.assert_(test_arrow_up in self.getBody(), "Error when sorting by quest giver")
# 
#         # Test basic search (by title)
#         basic_search_title = Lipsum().getUniqWord(length_min=1, length_max=10)
#         self.get(sorted_url + "&search=" + basic_search_title, 
#           description="Search for " + basic_search_title + " in title")
# 
#         # Test advanced search
#         self.get(server_url + "/new_search", description="Get advanced search page")
#         self.assert_("Title contains" in self.getBody(), "Error when loading advanced-search page")
# 
#         search_title = Lipsum().getUniqWord(length_min=1, length_max=10)
#         search_source = Lipsum().getAddress()
#         search_destination = Lipsum().getAddress()
#         search_reward_min = randint(1, 10000)
#         search_reward_max = randint(search_reward_min, 10000)
#         self.get(server_url + "/quests",
#         params=[['session[title]', search_title],
#         ['session[source]', search_source],
#         ['session[destination]', search_destination],
#         ['session[reward_min]', search_reward_min], 
#         ['session[reward_max]', search_reward_max],
#         ['commit', 'Search']],
#         description="Do a new advanced search")
#         self.assert_("Search in title" in self.getBody(), "Wrong quest page")
# 
#         # Test selecting a quest on a random page and viewing its content
#         self.get(server_url + "/quests", description="Go back to the basic quest browsing page")
#         quest_total = extract_token(self.getBody(), '<h3>Quests (', ')')
#         if not quest_total:
#             quest_total_num = 0
#         else:
#             quest_total_num = int(quest_total)
# 
#         if quest_total_num:
#             pages_total_num = int(ceil(quest_total_num / 10.0))
#             page_num = randint(1, pages_total_num)
#             self.get(server_url + "/quests?page=" + str(page_num), 
#                 description="Get the random page (page " + str(page_num) +")")
#             
#             # Check pagination when you have more than 1 page of quests
#             if pages_total_num > 1:
#                 assert_active_str = '<li class="active"><a href="/quests?page='+str(page_num)
#                 if page_num == 1 :
#                     assert_active_str = '<li class="active"><a rel="start" href="/quests?page=1'
#                 self.assert_(assert_active_str in self.getBody(),
#                  "Error when switching to page " + str(page_num))
    
#             # Click on "Accept Quest" 
#             quest_id_path = extract_token(self.getBody(), 'onclick="location.href=', '"')
#             quest_id_path = quest_id_path[1:-1]
#             self.get(server_url + quest_id_path, description="Select the topest quest on the current page")
#     
#             if "Accept Quest" in self.getBody(): 
#                 self.put(server_url + quest_id_path, 
#                 params=[['quest[quester_id]', user_id], 
#                   ['authenticity_token', auth_token],
#                   ['commit', 'Accept Quest'], 
#                   ['id', quest_id_path.split('/')[-1]]],
#                 description="Accept current quest")
#     
#                 self.assertEquals(self.getLastUrl(), quest_id_path, "Is not quest page")
#     
#                 if "Complete Quest" in self.getBody():
#                     self.put(server_url + quest_id_path, 
#                     params=[['quest[completed]', 'true'], 
#                       ['authenticity_token', auth_token],
#                       ['commit', 'Complete Quest'], 
#                       ['id', quest_id_path.split('/')[-1]]],
#                     description="Complete current quest")
#                     self.assert_("Quest complete!" in self.getBody(), "Not the correct page for the completed quest")
#             #     else:
#             #         self.assert_("Someone else has" in self.getBody(), "Not the correct page for the quest to be completed")
#            #  else:
#            #      self.assert_("Someone else has" in self.getBody(), "Not the correct page for the quest to be accepted")


        # Test user log-out
        self.get(server_url + "/logout",params=[['authenticity_token', auth_token_quest]],
            description="Test user log-out")
        self.assert_("Sign up now!" in self.getBody(), "Not the root page after user logged out")
        self.assert_("Log in" in self.getBody(), "Not the root page after user logged out")
Exemplo n.º 34
0
    def test_critical_path(self):
        server_url = self.server_url
        self.get(server_url, description='Get root URL')
        self.get(server_url + "/users/sign_up",
                 description="View the user signup page")

        auth_token = extract_token(
            self.getBody(), 'name="authenticity_token" type="hidden" value="',
            '"')
        email = Lipsum().getUniqWord() + "@" + Lipsum().getWord() + ".com"

        self.post(self.server_url + "/users",
                  params=[['user[email]', email],
                          ['user[password]', 'alphabet'],
                          ['user[password_confirmation]', 'alphabet'],
                          ['authenticity_token', auth_token],
                          ['commit', 'Sign up']],
                  description="Create New User")

        self.get(server_url + "/communities/new",
                 description="View the new communities page")
        auth_token = extract_token(
            self.getBody(), 'name="authenticity_token" type="hidden" value="',
            '"')

        community_name = Lipsum().getSentence()
        self.post(self.server_url + "/communities",
                  params=[['community[name]', community_name],
                          ['authenticity_token', auth_token],
                          ['commit', 'Create Community']],
                  description="Create New Community")
        last_url = self.getLastUrl()

        created_community_id = last_url.split('/')[-1]
        self.get(server_url + "/communities/" + created_community_id,
                 description="View the created community page")

        self.get(server_url + "/submissions/new",
                 description="View the new submissions page")
        auth_token = extract_token(
            self.getBody(), 'name="authenticity_token" type="hidden" value="',
            '"')

        submission_title = Lipsum().getSentence()
        submission_url = "http://www." + Lipsum().getWord() + Lipsum(
        ).getUniqWord() + ".com/"
        self.post(self.server_url + "/submissions",
                  params=[['submission[title]', submission_title],
                          ['submission[url]', submission_url],
                          ['submission[community_id]', created_community_id],
                          ['authenticity_token', auth_token],
                          ['commit', 'Create Submission']],
                  description="Create New Submission")
        last_url = self.getLastUrl()
        created_submission_id = last_url.split('/')[-1]

        self.get(server_url + "/comments/new",
                 description="View the new comments page")
        auth_token = extract_token(
            self.getBody(), 'name="authenticity_token" type="hidden" value="',
            '"')

        comment_message = Lipsum().getSentence()
        comment_parent = ''
        submission_id = created_submission_id
        self.post(self.server_url + "/comments",
                  params=[['comment[message]', comment_message],
                          ['comment[submission_id]', submission_id],
                          ['comment[parent_id]', comment_parent],
                          ['authenticity_token', auth_token],
                          ['commit', 'Create Comment']],
                  description="Create New Comment")
Exemplo n.º 35
0
    def test_foundry(self):
        # The description should be set in the configuration file
        server_url = self.server_url
        # begin of test ---------------------------------------------
        #self.get(server_url + "/blogposts/",
        #    description="Get /blogposts/")
        #self.get(server_url + "/listing/listing-large-set/",
        #    description="Get /listing/listing-large-set/")

        # Login
        self.get(server_url + "/login/",
            description="Get /login/")

        token = extract_token(self.getBody(), "name='csrfmiddlewaretoken' value='", "' />")
        self.post(server_url + "/login/", params=[
            ['username', 'alice'],
            ['csrfmiddlewaretoken', token],
            ['password', 'local'],
            ['next', '']],
            description="Post /login/")

        self.get(server_url + "/",
            description="Get /")

        # Navigate over blogposts
        self.get(server_url + "/blogposts/?by=most-liked",
            description="Get /blogposts/")

        #self.get(server_url + "/blogposts/?by=most-liked&for=this-month",
        #    description="Get /blogposts/")

        self.get(server_url + "/blogposts/?page=2",
            description="Get /blogposts/")

        self.get(server_url + "/blogposts/?page=3",
            description="Get /blogposts/")

        self.get(server_url + "/blogposts/?page=1000",
            description="Get /blogposts/")

        # Navigate over main page (tiled layout, paging affects all listings on
        # page so potentially expensive).
        self.get(server_url + "/?page=2",
            description="Get /")

        self.get(server_url + "/?page=3",
            description="Get /")

        # Navigate to an item and comment on it item 5 times
        self.get(server_url + "/blogpost/blog-post-10149",
            description="Get /blogpost/blog-post-10149")
        for i in range(0, 5):
            token = extract_token(self.getBody(), "name='csrfmiddlewaretoken' value='", "' />")
            security_hash = extract_token(self.getBody(), 'name="security_hash" value="', '" id="id_security_hash" />')
            timestamp = extract_token(self.getBody(), 'name="timestamp" value="', '" id="id_timestamp" />')
            self.post(server_url + "/comments/post/", params=[
                ['comment', 'A lovely comment %s %s' % (i, randint(1, 1000000))],
                ['name', 'Anonymous'],
                ['url', ''],
                ['timestamp', timestamp],
                ['object_pk', '10149'],
                ['next', '/blogpost/blog-post-10149/?paginate_by=&my_messages='],
                ['post', 'Post'],
                ['security_hash', security_hash],
                ['content_type', 'foundry.blogpost'],
                ['honeypot', ''],
                ['csrfmiddlewaretoken', token],
                ['in_reply_to', ''],
                ['email', '*****@*****.**']],
                description="Post /comments/post/")
            self.get(server_url + "/blogpost/blog-post-10149",
                description="Get /blogpost/blog-post-10149")

        # Create blogpost start
        self.get(server_url + "/create-blogpost/",
            description="Get /create-blogpost/")

        token = extract_token(self.getBody(), "name='csrfmiddlewaretoken' value='", "' />")
        self.post(server_url + "/create-blogpost/", params=[
            ['content', ''],
            ['csrfmiddlewaretoken', token],
            ['title', '']],
            description="Post /create-blogpost/")

        token = extract_token(self.getBody(), "name='csrfmiddlewaretoken' value='", "' />")
        self.post(server_url + "/create-blogpost/", params=[
            ['content', 'Made by funkload'],
            ['csrfmiddlewaretoken', token],
            ['title', 'A new blogpost']],
            description="Post /create-blogpost/")

        # Logout
        self.get(server_url + "/logout/",
            description="Get /logout/")       
    def view_stuff(self):
        server_url = self.server_url
       
        self.get(server_url + "/upcoming", description="View the upcoming page")
      
        self.get(server_url + "/index", description="View the index page")

        self.get(server_url + "/users/sign_up", description="View the user signup page")
        auth_token = extract_token(self.getBody(), 'name="authenticity_token" type="hidden" value="', '"')
        email = Lipsum().getUniqWord() + "@" + Lipsum().getWord() + ".com"
        name = Lipsum().getUniqWord()
     
        self.post(self.server_url + "/users",
                params=[['user[name]',name],
                ['user[email]', email],
                  ['user[password]', 'alphabet'],
                  ['user[password_confirmation]', 'alphabet'],
                  ['authenticity_token', auth_token],
                  ['commit', 'Sign up']],
                description="Create New User")

        last_url = self.getLastUrl()
        user_id = last_url.split('/')[-1]
        self.get(server_url+"/closeparties",description="watch the close parties")   
    
            #self.get(server_url + "/index", description="View the indexpage2")
            #auth_token = extract_token(self.getBody(), 'name="authenticity_token" type="hidden" value="', '"')
        self.get(server_url + "/new", description="view party page")
        auth_token = extract_token(self.getBody(), 'name="authenticity_token" type="hidden" value="', '"')
   
        self.post(self.server_url + "/parties",
                params=[['party[name]', Lipsum().getUniqWord()],
                  ['party[owner]', name],
                  ['party[date]', '2016-12-03'],
                  ['party[time]', '17:00'],
                  ['party[location]',Lipsum().getUniqWord()],
                  ['party[description]',Lipsum().getUniqWord()],
                  ['authenticity_token', auth_token],
                  ['commit', 'Sign up']],
                description="Create New party")
            
        last_url = self.getLastUrl()
        created_party_id = last_url.split('/')[-1]

        
  
        
        #self.get(server_url + "/invitetoparty/"+created_party_id, description="View invite page ")
        #auth_token = extract_token(self.getBody(), 'name="authenticity_token" type="hidden" value="', '"')
        
        for i in range (10,13):
 
            self.post(self.server_url + "/createasinvite",
                    params=[['party_id',created_party_id ],
                     ['user_id', i],
                     ['authenticity_token', auth_token],
                     ['commit', 'Sign up']],
                     description="Inviting user")



        self.get(server_url + "/index", description="View index page ")

        auth_token = extract_token(self.getBody(), 'name="authenticity_token" type="hidden" value="', '"')
        
        for i in range (15,18):


            self.post(self.server_url + "/join_members",
                    params=[['party_id',i],
                     ['user_id', user_id],
                     ['authenticity_token', auth_token],
                     ['commit', 'Sign up']],
                     description="Asking to join")

        self.get(server_url + "/myparties", description="View my parties page")
        self.get(server_url + "/partyrequest", description="View requests page")
Exemplo n.º 37
0
    def test_practice(self):
        # The description should be set in the configuration file
        server_url = self.server_url
        # begin of test ---------------------------------------------

        # /tmp/tmpCz5DHd_funkload/watch0001.request
        self.get(server_url + "/",
            description="Get /")
        # /tmp/tmpCz5DHd_funkload/watch0090.request
        self.logd("Getting login form.")
        self.post(server_url + "/login_form", params=[
            ['came_from', self.server_url],
            ['next', ''],
            ['ajax_load', ''],
            ['ajax_include_head', ''],
            ['target', ''],
            ['mail_password_url', ''],
            ['join_url', ''],
            ['form.submitted', '1'],
            ['js_enabled', '0'],
            ['cookies_enabled', ''],
            ['login_name', ''],
            ['pwd_empty', '0'],
            ['__ac_name', self.login],
            ['__ac_password', self.password],
            ['submit', 'Sign in']],
            description="Post /login_form")

        self.logd("Getting practice page.")
        self._accept_invalid_links = True
        self.get(server_url + "/@@practice/grade-10",
            description="Get /@@practice/grade-10")

        self.logd("Getting practice chapter.")
        self.get(server_url + "/@@practice/select_chapter/5",
            description="Get /@@practice/select_chapter/5")
        rtoken = 'Random seed: </b>'
        ttoken = 'Template id: </b>'
        end = '</div>'

        for count in range(0,9):
            self.logd("Getting questions.")
            seed = int(extract_token(self.getBody(), rtoken, end))
            template_id = int(extract_token(self.getBody(), ttoken, end))
            answers_url = '%s/?templateId=%s&seed=%s' % (self.answer_server_url,
                                                         template_id,
                                                         seed)
            response = requests.get(answers_url)

            answers = eval(response.text)
            postData = {}
            for questionIdx, subanswers in enumerate(answers):
                questionNumber = questionIdx +1
                for answerIdx, answer in enumerate(subanswers):
                    answerNumber = chr(ord('a')+answerIdx)
                    key = 'question%s%s' % (questionNumber, answerNumber)
                    postData[key] = answer

            self.post(server_url + "/@@practice/submit_response",
                      params=postData,
                      description="Post /@@practice/submit_response")
            self.assert_('Correct!' in self.getBody(), "Answer incorrect.")

            postData = {'nextPage': 'Go to next question'}
            self.post(server_url + "/@@practice/submit_response",
                      params=postData,
                      description="Post /@@practice/submit_response")