def createStudent(self, user): """Create a student role for user. """ # Create a student for a_user given_name = 'A' surname = 'Student' res_street = 'A Street' res_city = 'A City' res_country = 'United Kingdom' res_postalcode = 'A Postalcode' phone = '01234567' birth_date = db.DateProperty.now() properties = { 'link_id': user.link_id, 'scope_path': 'google', 'user': user, 'given_name': given_name, 'surname': surname, 'email': user.account.email(), 'res_street': res_street, 'res_city': res_city, 'res_country': res_country, 'res_postalcode': res_postalcode, 'phone': phone, 'birth_date': birth_date, 'school_name': 'School', 'school_country': 'United States', 'expected_graduation': 2012, 'program_knowledge': 'Knowledge', } student = student_logic.updateOrCreateFromFields(properties) return student, properties
def testUpdateStudent(self): """Test that student role can be updated for a user. """ student, properties = self.createStudent(self.user) old_given_name = properties['given_name'] new_given_name = 'New' properties = { 'link_id': self.user.link_id, 'scope_path': 'google', 'given_name': new_given_name, } student = student_logic.updateOrCreateFromFields(properties) updated_given_name = getattr(student, 'given_name') self.assertEqual(updated_given_name , new_given_name) self.assertNotEqual(updated_given_name, old_given_name)
def testUpdateStudent(self): """Test that student role can be updated for a user. """ student, properties = self.createStudent(self.user) old_given_name = properties['given_name'] new_given_name = 'New' properties = { 'link_id': self.user.link_id, 'scope_path': 'google', 'given_name': new_given_name, } student = student_logic.updateOrCreateFromFields(properties) updated_given_name = getattr(student, 'given_name') self.assertEqual(updated_given_name, new_given_name) self.assertNotEqual(updated_given_name, old_given_name)
def setUp(self): """Set up required for the view tests. """ # Create a user for sponsor email = "*****@*****.**" account = users.User(email=email) link_id = 'a_sponsor_user' name = 'A Sponsor User' sponsor_user_properties = { 'account': account, 'link_id': link_id, 'name': name, } self.sponsor_user = user_logic.updateOrCreateFromFields( sponsor_user_properties) # Create sponsor role for a_sponsor_user link_id = 'a_sponsor' name = link_id phone = '01234567' contact_postalcode = 'A postalcode' description = 'A description' contact_country = 'United States' short_name = 'AS' contact_city = 'A city' home_page = 'http://www.asponsor.com' email = '*****@*****.**' sponsor_properties = { 'link_id': link_id, 'name': name, 'short_name': short_name, 'founder': self.sponsor_user, 'phone': phone, 'description': description, 'contact_country': contact_country, 'contact_city': contact_city, 'contact_street': 'A Street', 'contact_postalcode': contact_postalcode, 'home_page': home_page, 'email': email, } self.sponsor = sponsor_logic.updateOrCreateFromFields(sponsor_properties) # Create a timeline for a program timeline_properties = { 'link_id': 'a_program', 'scope_path': 'a_sponsor', 'scope': self.sponsor, } self.timeline = timeline_logic.updateOrCreateFromFields( timeline_properties) # Create a program for a_sponsor program_properties = { 'link_id': 'a_program', 'scope': self.sponsor, 'scope_path': 'a_sponsor', 'name': 'A Program 2010', 'short_name': 'AP2010', 'group_label': 'AP', 'description': 'This is the program for AP2010.', 'apps_tasks_limit': 42, 'slots': 42, 'timeline': self.timeline, 'status': 'visible', } self.program = program_logic.updateOrCreateFromFields(program_properties) # Create another user for student email = "*****@*****.**" account = users.User(email=email) link_id = 'a_student_user' name = 'A Student User' student_user_properties = { 'account': account, 'link_id': link_id, 'name': name, } self.student_user = user_logic.updateOrCreateFromFields( student_user_properties) # Create student role for a_user student_properties = { 'link_id': 'a_student', 'scope_path': 'a_sponsor/a_program', 'scope': self.program, 'user' : self.student_user, 'given_name': 'Student', 'surname': 'Last Name', 'name_on_documents': 'Test Example', 'birth_date': db.DateProperty.now(), 'email': '*****@*****.**', 'res_street': 'Some Street', 'res_city': 'A City', 'res_state': 'A State', 'res_country': 'United States', 'res_postalcode': '12345', 'phone': '1-555-BANANA', 'agreed_to_tos': True, 'school_name': 'School', 'school_country': 'United States', 'major': 'Computer Science', 'degree': 'Undergraduate', 'expected_graduation': 2012, 'program_knowledge': 'Knowledge', 'school': None, 'can_we_contact_you': True, } self.student = student_logic.updateOrCreateFromFields(student_properties) self.scope_path = self.student.scope_path self.link_id = self.student.link_id
def setUp(self): """Set up required for the view tests. """ # Create a user for sponsor email = "*****@*****.**" account = users.User(email=email) link_id = 'a_sponsor_user' name = 'A Sponsor User' sponsor_user_properties = { 'account': account, 'link_id': link_id, 'name': name, } self.sponsor_user = user_logic.updateOrCreateFromFields( sponsor_user_properties) # Create sponsor role for a_sponsor_user link_id = 'a_sponsor' name = link_id phone = '01234567' contact_postalcode = 'A postalcode' description = 'A description' contact_country = 'United States' short_name = 'AS' contact_city = 'A city' home_page = 'http://www.asponsor.com' email = '*****@*****.**' sponsor_properties = { 'link_id': link_id, 'name': name, 'short_name': short_name, 'founder': self.sponsor_user, 'phone': phone, 'description': description, 'contact_country': contact_country, 'contact_city': contact_city, 'contact_street': 'A Street', 'contact_postalcode': contact_postalcode, 'home_page': home_page, 'email': email, } self.sponsor = sponsor_logic.updateOrCreateFromFields( sponsor_properties) # Create a timeline for a program timeline_properties = { 'link_id': 'a_program', 'scope_path': 'a_sponsor', 'scope': self.sponsor, } self.timeline = timeline_logic.updateOrCreateFromFields( timeline_properties) # Create a program for a_sponsor program_properties = { 'link_id': 'a_program', 'scope': self.sponsor, 'scope_path': 'a_sponsor', 'name': 'A Program 2010', 'short_name': 'AP2010', 'group_label': 'AP', 'description': 'This is the program for AP2010.', 'apps_tasks_limit': 42, 'slots': 42, 'timeline': self.timeline, 'status': 'visible', } self.program = program_logic.updateOrCreateFromFields( program_properties) # Create another user for student email = "*****@*****.**" account = users.User(email=email) link_id = 'a_student_user' name = 'A Student User' student_user_properties = { 'account': account, 'link_id': link_id, 'name': name, } self.student_user = user_logic.updateOrCreateFromFields( student_user_properties) # Create student role for a_user student_properties = { 'link_id': 'a_student', 'scope_path': 'a_sponsor/a_program', 'scope': self.program, 'user': self.student_user, 'given_name': 'Student', 'surname': 'Last Name', 'name_on_documents': 'Test Example', 'birth_date': db.DateProperty.now(), 'email': '*****@*****.**', 'res_street': 'Some Street', 'res_city': 'A City', 'res_state': 'A State', 'res_country': 'United States', 'res_postalcode': '12345', 'phone': '1-555-BANANA', 'agreed_to_tos': True, 'school_name': 'School', 'school_country': 'United States', 'major': 'Computer Science', 'degree': 'Undergraduate', 'expected_graduation': 2012, 'program_knowledge': 'Knowledge', 'school': None, 'can_we_contact_you': True, } self.student = student_logic.updateOrCreateFromFields( student_properties) self.scope_path = self.student.scope_path self.link_id = self.student.link_id