blob: 2ed3bf2efa2bc67add973457d8b5e0597aa6e1be [file] [log] [blame]
# Copyright 2014 the Melange authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Test case for GSoC student registration process."""
from tests import timeline_utils
from tests.functional import melange_functional_actions
class StudentRegistrationTest(melange_functional_actions.FunctionalTestCase):
def setUp(self):
self.init()
self.createGSoCProgram()
self.timeline = timeline_utils.GSoCTimelineHelper(
self.gsoc.timeline, self.org_app)
self.timeline.studentSignup()
# TODO(nathaniel): Extract this giant list of dicts in to a constant.
self.properties = [
{"Object":"Url",
"Identification":"http://localhost:%d/gsoc/homepage/" % self.port,
"Value":None},
{"Object":"How Google Summer of Code Works",
"Identification":"title-section-how-it-works",
"Value":"How Google Summer of Code Works"},
{"Object":"Register_Button",
"Identification":"//*[@id='block-apply-text-action']/a",
"Value":None},
{"Object":"Login_email_localhost",
"Identification":"email",
"Value":"test101@gmail.com"},
{"Object":"Sign_in_button_localhost",
"Identification":"submit-login",
"Value":None},
{"Object":"Google_account",
"Identification":"email",
"Value":None},
{"Object":"Password_for_google_account",
"Identification":"Passwd",
"Value":None},
{"Object":"Sign_in",
"Identification":"signIn",
"Value":None},
{"Object":"User_name",
"Identification":"//*[@id='user_id']",
"Value":"lucy12"},
{"Object":"Public_name",
"Identification":"public_name",
"Value":"Lucy"},
{"Object":"First_name",
"Identification":"//*[@id='first_name']",
"Value":"Lucy"},
{"Object":"Last_name",
"Identification":"//*[@id='last_name']",
"Value":"Mcmaan"},
{"Object":"Email",
"Identification":"email",
"Value":"lucy@gmail.com"},
{"Object":"Residential_street",
"Identification":"residential_street",
"Value":"alpha street"},
{"Object":"Residential_street_extra",
"Identification":"residential_street_extra",
"Value":"beta street"},
{"Object":"City",
"Identification":"residential_city",
"Value":"New Delhi"},
{"Object":"State",
"Identification":"residential_province",
"Value":"New Delhi"},
{"Object":"Country",
"Identification":"residential_country",
"Value":"India"},
{"Object":"Postal_code",
"Identification":"residential_postal_code",
"Value":"98765"},
{"Object":"Phone",
"Identification":"phone",
"Value":"09876546789"},
{"Object":"Publish_my_location",
"Identification":"publish_location",
"Value":None},
{"Object":"Full_recipient_name",
"Identification":"ship_name",
"Value":"Donald Mcmann"},
{"Object":"Shipping_street",
"Identification":"ship_street",
"Value":"alpha street"},
{"Object":"Shipping_street_extra",
"Identification":"ship_street_extra",
"Value":"beta street"},
{"Object":"Shipping_city",
"Identification":"ship_city",
"Value":"New Delhi"},
{"Object":"Shipping_state",
"Identification":"ship_state",
"Value":"New Delhi"},
{"Object":"Shipping_country",
"Identification":"ship_country",
"Value":"India"},
{"Object":"Shipping_postal_code",
"Identification":"ship_postalcode",
"Value":"98765"},
{"Object":"Birth_date",
"Identification":"birth_date",
"Value":"1990-08-09"},
{"Object":"T_shirt_style",
"Identification":"tee_style",
"Value":"female"},
{"Object":"T_shirt_size",
"Identification":"tee_size",
"Value":"m"},
{"Object":"Gender",
"Identification":"gender",
"Value":"female"},
{"Object":"How_did_you_hear_about_gsoc",
"Identification":"program_knowledge",
"Value":"friend"},
{"Object":"I_agree",
"Identification":"agreed_to_tos",
"Value":None},
{"Object":"Notify_to_new_public_comments",
"Identification":"notify_public_comments",
"Value":None},
{"Object":"School_name",
"Identification":"school_name",
"Value":"Delhi University"},
{"Object":"School_country",
"Identification":"school_country",
"Value":"India"},
{"Object":"Major_subject",
"Identification":"major",
"Value":"Computer"},
{"Object":"Degree",
"Identification":"degree",
"Value":"undergraduate"},
{"Object":"Expected_graduation",
"Identification":"expected_graduation",
"Value":"2012"},
{"Object":"School_homepage",
"Identification":"school_web_page",
"Value":"www.abc.com"},
{"Object":"Submit_button",
"Identification":"form-register-submit",
"Value":None},
{"Object":"Message_from_melange",
"Identification":"//*[@id='flash-message']/p",
"Value": ("Sorry, we could not save your data."
"Please fix the errors mentioned below.")},
{"Object":"Terms_of_service",
"Identification":"//*[@id='terms_of_service']",
"Value": None},
]
def testGSoCRegisterAsAStudent(self):
# Load test data.
self.loadProperties()
# Test url, Change it according to your environment.
self.openUrl("gsoc")
self.waitForPageLoad()
# Scroll down.
self.scrollDown()
# Click on Register.
self.clickOn("Register_Button")
# Login on melange.
self.waitForNameExists("continue") # "continue" is the bottom
# input box on the appengine
# dev login form
self.login()
# After logging in, try to create profile.
self.waitForPageLoad()
self.clickOn("Register_Button")
self.waitForPageLoad()
# Make sure we've ended up on the right page:
self.assertIn("/register/", self.Browser.current_url)
self.writeTextField("User_name")
# Fill the public name field.
self.writeTextField("Public_name")
self.scrollDown()
# Enter given Name.
self.writeTextField("First_name")
# Enter surname.
self.writeTextField("Last_name")
# Enter email.
self.writeTextField("Email")
# Enter residential street address.
self.writeTextField("Residential_street")
# Enter extra residential address.
self.writeTextField("Residential_street_extra")
# Enter the city.
self.writeTextField("City")
# Enter state.
self.writeTextField("State")
# Traverse through country names and select a country from the list.
self.setDropDownList("Country")
# Enter postal code.
self.writeTextField("Postal_code")
# Enter phone number.
self.writeTextField("Phone")
# Enter the date of birth.
self.writeTextField("Birth_date")
# Traverse through the list and select t-shirt style.
self.setDropDownList("T_shirt_style")
# Traverse through the list and select a t-shirt size.
self.setDropDownList("T_shirt_size")
# Select gender as female.
self.setDropDownList("Gender")
# Select program knowledge as friend.
self.setDropDownList("How_did_you_hear_about_gsoc")
# Enter school name.
self.writeTextField("School_name")
# Select school country.
self.setDropDownList("School_country")
# Enter major subject.
self.writeTextField("Major_subject")
# Select degree.
self.setDropDownList("Degree")
# Enter expected graduation.
self.writeTextField("Expected_graduation")
# Enter school homepage URL.
self.writeTextField("School_homepage")
self.toggleCheckBox("Terms_of_service")
# Submit!
self.clickOn("Submit_button")
self.waitForPageLoad()
# Make sure we've ended up on the right page:
self.assertIn("/profile/show/", self.Browser.current_url)
self.assertIn("validated=true", self.Browser.current_url)
flash_message = self.Browser.find_elements_by_id("flash-message")
self.assertEqual(
flash_message[0].text, "Your profile was saved successfully.")
def tearDown(self):
self.terminateInstance()