def setUp(self): """Set up required for the view tests. """ # Ensure that current user with developer privilege is created user_properties = { 'account': users.get_current_user(), 'link_id': 'current_user', 'name': 'Current User', 'is_developer': True, } user_logic.updateOrCreateFromFields(user_properties)
def testUpdateUserCapsEntity(self): """Test that capital email address will be denormalized on update. """ email = "*****@*****.**" account = users.User(email=email) name = 'Updated User' properties = { 'account': account, 'link_id': self.entity.link_id, 'name': name, } user_logic.updateOrCreateFromFields(properties) entity = user_logic.getFromKeyName(self.entity.link_id) denormalized = accounts.denormalizeAccount(entity.account) self.failUnlessEqual(account.email().lower(), denormalized.email())
def testUpdateUserNormalEntity(self): """Test that a user can be updated. """ email = "*****@*****.**" account = users.User(email=email) name = 'Updated User' properties = { 'account': account, 'link_id': self.entity.link_id, 'name': name, } user_logic.updateOrCreateFromFields(properties) entity = user_logic.getFromKeyName(self.entity.link_id) self.failUnlessEqual(account.email().lower(), email.lower()) self.failUnlessEqual(account, entity.account) self.failUnlessEqual(name, entity.name)
def setUp(self): """Set up required for the cleaning logic tests. """ # Ensure that current user is created user_properties = { 'account': users.get_current_user(), 'link_id': 'current_user', 'name': 'Current User', } self.user = user_logic.updateOrCreateFromFields(user_properties) # Create another user another_user_properties = { 'account': users.User(email="*****@*****.**"), 'link_id': 'another_user', 'name': 'Another User', } self.another_user = user_logic.updateOrCreateFromFields( another_user_properties) # Create a dummy form object self.form = Form()
def createCurrentUser(self): """Create the current user. """ properties = { 'account': users.get_current_user(), 'link_id': 'current_user', 'name': 'Current User', } current_user = user_logic.updateOrCreateFromFields(properties) entity = user_logic.getCurrentUser() return entity
def testUpdateUserInvalidUpdate(self): """Test that the ToS fields can't be changed once the user agreed ToS. """ email = "*****@*****.**" account = users.User(email=email) name = 'Updated User' agreed_to_tos = False properties = { 'account': account, 'link_id': self.entity.link_id, 'name': name, 'agreed_to_tos': agreed_to_tos, } user_logic.updateOrCreateFromFields(properties) entity = user_logic.getFromKeyName(self.entity.link_id) self.failUnlessEqual(account.email().lower(), email.lower()) self.failUnlessEqual(account, entity.account) self.failUnlessEqual(name, entity.name) self.failIfEqual(agreed_to_tos, entity.agreed_to_tos)
def setUp(self): """Set up required for the student role tests. """ # Create a user to experiment on email = "*****@*****.**" account = users.User(email=email) link_id = 'a_user' name = 'A User' properties = { 'account': account, 'link_id': link_id, 'name': name, 'user_id': link_id, } self.user = user_logic.updateOrCreateFromFields(properties)
def setUp(self): """Set up required for the slot allocation tests. """ # Create a user to experiment on email = "*****@*****.**" account = users.User(email=email) link_id = 'a_user' name = 'A User' properties = { 'account': account, 'link_id': link_id, 'name': name, 'agreed_to_tos': True, 'user_id': link_id, } self.entity = user_logic.updateOrCreateFromFields(properties)
def setUp(self): """Set up required for the view tests. """ # Setup TaskQueueTestCase and MailTestCase first super(SurveysTasksTest, self).setUp() # Create a user for the founder of 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, } sponsor_user = user_logic.updateOrCreateFromFields( sponsor_user_properties) # Create sponsor link_id = 'a_sponsor' name = 'A Sponsor' founder = 'a_founder' 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': sponsor_user, 'phone': phone, 'description': description, 'contact_country': contact_country, 'contact_city': 'A City', 'contact_street': 'A Street', 'contact_postalcode': contact_postalcode, 'home_page': home_page, 'email': email, 'status': 'active', } sponsor = sponsor_logic.updateOrCreateFromFields(sponsor_properties) # Create a timeline for a program timeline_properties = { 'link_id': 'a_program', 'scope_path': 'a_sponsor', 'scope': sponsor, } timeline = timeline_logic.updateOrCreateFromFields(timeline_properties) # Create a program for a_sponsor program_properties = { 'key_name': 'a_sponsor/a_program', 'link_id': 'a_program', 'scope': 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, 'allocations_visible': True, 'timeline': timeline, 'status': 'visible', } # GSoC program logic does not work: error in updatePredefinedOrgTags from soc.modules.gsoc.models.program import GSoCProgram program = GSoCProgram(**program_properties) program.put() self.program = program # Create an organization for a_program organization_properties = { 'link_id': 'an_org', 'name': 'An Organization', 'short_name': 'AO', 'scope_path': 'a_sponsor/a_program', 'scope': program, 'founder': sponsor_user, 'home_page': 'http://www.an_org.com', 'phone': '1-555-2222', 'description': 'An Organization', 'license_name': 'Apache License', 'ideas': 'http://www.an_org.com/ideas', 'contact_country': contact_country, 'contact_city': 'A City', 'contact_street': 'A Street', 'contact_postalcode': contact_postalcode, 'home_page': home_page, 'email': email, 'status': 'active', } organization = gsoc_organization_logic.updateOrCreateFromFields( organization_properties) # Create a user for all roles except sponsor email = "*****@*****.**" account = users.User(email=email) link_id = 'a_role_user' name = 'A Role User' properties = { 'account': account, 'link_id': link_id, 'name': name, } key_name = user_logic.getKeyNameFromFields(properties) role_user = user_logic.updateOrCreateFromKeyName(properties, key_name) # Create an admin for an_org gsoc_org_admin_properties = { 'link_id': 'an_org_admin', 'given_name': 'A', 'surname': 'Orgadmin', 'scope_path': organization.scope_path + '/' + organization.link_id, 'scope': organization, 'program': program, 'phone': '1-555-2222', 'email': '*****@*****.**', 'res_country': 'United States', 'res_city': 'A City', 'res_street': 'A Street', 'res_postalcode': '12345', 'birth_date': db.DateProperty.now(), 'user': role_user, } gsoc_org_admin_logic.updateOrCreateFromFields( gsoc_org_admin_properties) # Create a mentor for an_org mentor_properties = gsoc_org_admin_properties.copy() mentor_properties.update({ 'link_id': 'a_mentor', 'given_name': 'A', 'surname': 'Mentor', 'email': '*****@*****.**', }) mentor = mentor_logic.updateOrCreateFromFields(mentor_properties) self.mentor = mentor # Create students for a_program student_properties = gsoc_org_admin_properties.copy() student_properties.update({ 'scope_path': program.scope_path + '/' + program.link_id, 'scope': program, 'program': program, 'given_name': 'A', 'surname': 'Student', 'major': 'A Major', 'name_on_documents': 'A Name on Documents', 'publish_location': True, 'blog': 'http://www.ablog.com/', 'home_page': 'http://www.ahomepage.com/', 'photo_url': 'http://www.astudent.com/aphoto.png', 'expected_graduation': 2011, 'school_country': 'United States', 'school_name': 'A School', 'tshirt_size': 'XS', 'tshirt_style': 'male', 'degree': 'Undergraduate', 'phone': '1650253000', 'can_we_contact_you': True, 'program_knowledge': 'I heard about this program through a friend.' }) # Create projects for a_program, an_org and a_mentor project_properties = { 'scope_path': organization.scope_path + '/' + organization.link_id, 'scope': organization, 'title': 'test project', 'abstract': 'test abstract', 'status': 'accepted', 'mentor': mentor, 'program': program, } #The string order of students' link_id is the same with that of students #in the array in order to make sure the last student is handled last size = 10 self.num_projects = size + 1 num_digits = 0 while True: size /= 10 num_digits += 1 if size == 0: break students, projects = [], [] for i in xrange(self.num_projects): student_link_id = ('student%0' + str(num_digits) + 'd') % i student_properties.update({ 'link_id': student_link_id, 'email': student_link_id + '@email.com', }) student = student_logic.updateOrCreateFromFields( student_properties) students.append(student) project_link_id = ('project%0' + str(num_digits) + 'd') % i project_properties.update({ 'link_id': project_link_id, 'student': student, }) project = student_project_logic.updateOrCreateFromFields( project_properties) projects.append(project) self.students = students self.projects = projects # Create a project survey for a_program link_id = 'a_project_survey' fields = { 'SelectionQ': [ u'SelectionQ Option 2 for %s' % link_id, u'SelectionQ Option 1 for %s' % link_id ], 'PickMultipleQ': [ 'PickMultipleQ Checkbox 1 for %s' % link_id, 'PickMultipleQ Checkbox 2 for %s' % link_id, ], 'LongQ': 'LongQ Custom Prompt for %s' % link_id, 'ShortQ': 'ShortQ Custom Prompt for %s' % link_id, } schema = { u'PickMultipleQ': { 'index': 5, 'type': 'pick_multi', 'render': 'multi_checkbox' }, u'LongQ': { 'index': 2, 'type': 'long_answer' }, u'ShortQ': { 'index': 3, 'type': 'short_answer' }, u'SelectionQ': { 'index': 4, 'type': 'selection', 'render': 'single_select' } } survey_properties = { 'link_id': link_id, 'scope_path': program.scope_path + '/' + program.link_id, 'scope': None, 'prefix': 'program', 'author': role_user, 'title': 'A Project Survey', 'short_name': 'APS', 'modified_by': role_user, 'is_featured': True, 'fields': fields, 'schema': schema, 'deadline': datetime.datetime.now() + datetime.timedelta(10), 'taking_access': 'student', } project_survey = project_survey_logic.updateOrCreateFromFields( survey_properties) self.project_survey = project_survey # Create a grading survey for a_program link_id = 'a_grading_survey' survey_properties.update({ 'link_id': link_id, 'title': 'A Grading Survey', 'short_name': 'AGS', 'taking_access': 'mentor', }) grading_survey = grading_survey_logic.updateOrCreateFromFields( survey_properties) self.grading_survey = grading_survey
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 createOrgAdminUserForAnotherOrg(self, with_oa_entity=False): """Create another organization, user and invitation for the user """ # Create a user for org admin who is also the founder of the another_org email = '*****@*****.**' account = users.User(email=email) link_id = 'another_org_oa_user' name = 'Another Org Org Admin User' oa_user_properties = { 'account': account, 'link_id': link_id, 'name': name, 'agreed_to_tos': True, } self.another_org_oa_user = user_logic.updateOrCreateFromFields( oa_user_properties) # create another org for the program org_properties = { 'link_id': 'another_org', 'scope': self.program, 'scope_path': self.program.key().id_or_name(), 'name': 'Another Organization', 'short_name': 'Another Org', 'founder': self.another_org_oa_user, 'home_page': 'http://anotherorg.com', 'email': '*****@*****.**', 'description': 'Another Organization Description', 'contact_street': 'Another Organization Street', 'contact_city': 'Another Organization City', 'contact_country': 'Sweden', 'contact_postalcode': '5653276 NG', 'phone': '61-434-BLUE', 'status': 'active', } self.another_org = org_logic.updateOrCreateFromFields(org_properties) request_properties = { 'role': 'gsoc_org_admin', 'user': self.another_org_oa_user, 'group': self.another_org, 'message': 'An Invitation Request Message', 'status': 'group_accepted', } self.another_org_request = request_logic.updateOrCreateFromFields( request_properties) if with_oa_entity: # create a second org admin role for the second org admin user oa_properties = { 'link_id': 'another_org_org_admin', 'scope_path': self.another_org.key().id_or_name(), 'scope': self.another_org, 'program': self.program, 'user': self.another_org_oa_user, 'given_name': 'AnotherOrgOrgAdmin', 'surname': 'AnotherOrgAdministrator', 'name_on_documents': 'AnotherOrgOrgAdmin Administrator', 'birth_date': datetime.date(1975, 12, 15), 'email': '*****@*****.**', 'res_street': 'Another Org Admin Street', 'res_city': 'Another Org Admin City', 'res_state': 'Another Org Admin State', 'res_country': 'Netherlands', 'res_postalcode': '572461', 'phone': '72-534-COLORLESS', 'agreed_to_tos': True, } # create the org_admin_entity self.another_org_oa = gsoc_oa_logic.updateOrCreateFromFields( oa_properties) # Create an user for second org admin for another org email = '*****@*****.**' account = users.User(email=email) link_id = 'another_org_another_oa_user' name = 'Another Org Admin User' oa_user_properties = { 'account': account, 'link_id': link_id, 'name': name, 'agreed_to_tos': True, } self.another_org_oa_user = user_logic.updateOrCreateFromFields( oa_user_properties) request_properties = { 'role': 'gsoc_org_admin', 'user': self.another_org_oa_user, 'group': self.another_org, 'message': 'An Invitation Request Message', 'status': 'group_accepted', } self.another_org_second_request = request_logic.updateOrCreateFromFields( request_properties)
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': self.sponsor.key().id_or_name(), '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 org admin who is also the founder of the org email = '*****@*****.**' account = users.User(email=email) link_id = 'an_org_admin_user' name = 'An Org Admin User' org_admin_user_properties = { 'account': account, 'link_id': link_id, 'name': name, } self.org_admin_user = user_logic.updateOrCreateFromFields( org_admin_user_properties) # create an org for the program org_properties = { 'link_id': 'an_org', 'scope': self.program, 'scope_path': self.program.key().id_or_name(), 'name': 'An Organization', 'short_name': 'An Org', 'founder': self.org_admin_user, 'home_page': 'http://anorg.com', 'email': '*****@*****.**', 'description': 'An Organization Description', 'contact_street': 'An Organization Street', 'contact_city': 'An Organization City', 'contact_country': 'United Kingdom', 'contact_postalcode': '0123456 AnO', 'phone': '1-555-BANANA', 'status': 'active', } self.org = org_logic.updateOrCreateFromFields(org_properties) # Create an org admin role for a_user org_admin_properties = { 'link_id': 'an_org_admin', 'scope_path': self.org.key().id_or_name(), 'scope': self.org, 'program': self.program, 'user': self.org_admin_user, 'given_name': 'OrgAdmin', 'surname': 'Administrator', 'name_on_documents': 'OrgAdmin Administrator', 'birth_date': datetime.date(1970, 1, 1), 'email': '*****@*****.**', 'res_street': 'An Org Admin Street', 'res_city': 'An Org Admin City', 'res_state': 'An Org Admin State', 'res_country': 'France', 'res_postalcode': '12345', 'phone': '1-555-BANANA', 'agreed_to_tos': True, } # create the org_admin_entity self.org_admin = org_admin_logic.updateOrCreateFromFields( org_admin_properties) self.scope_path = self.org_admin.scope_path self.link_id = self.org_admin.link_id
def setUp(self): """Set up required for the view tests. """ # Setup TaskQueueTestCase and MailTestCase first super(GradingSurveyGroupTasksTest, self).setUp() # Create a user for the founder of 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, } sponsor_user = user_logic.updateOrCreateFromFields(sponsor_user_properties) # Create sponsor link_id = 'a_sponsor' name = 'A Sponsor' founder = 'a_founder' 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': sponsor_user, 'phone': phone, 'description': description, 'contact_country': contact_country, 'contact_city': 'A City', 'contact_street': 'A Street', 'contact_postalcode': contact_postalcode, 'home_page': home_page, 'email': email, 'status': 'active', } sponsor = sponsor_logic.updateOrCreateFromFields(sponsor_properties) # Create a timeline for a program timeline_properties = { 'link_id': 'a_program', 'scope_path': 'a_sponsor', 'scope': sponsor, } timeline = timeline_logic.updateOrCreateFromFields(timeline_properties) # Create a program for a_sponsor program_properties = { 'key_name': 'a_sponsor/a_program', 'link_id': 'a_program', 'scope': 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, 'allocations_visible': True, 'timeline': timeline, 'status': 'visible', } # GSoC program logic does not work: error in updatePredefinedOrgTags from soc.modules.gsoc.models.program import GSoCProgram program = GSoCProgram(**program_properties) program.put() self.program = program # Create an organization for a_program organization_properties = { 'link_id': 'an_org', 'name': 'An Organization', 'short_name': 'AO', 'scope_path': 'a_sponsor/a_program', 'scope': program, 'founder': sponsor_user, 'home_page': 'http://www.an_org.com', 'phone': '1-555-2222', 'description': 'An Organization', 'license_name': 'Apache License', 'ideas': 'http://www.an_org.com/ideas', 'contact_country': contact_country, 'contact_city': 'A City', 'contact_street': 'A Street', 'contact_postalcode': contact_postalcode, 'home_page': home_page, 'email': email, 'status': 'active', } organization = gsoc_organization_logic.updateOrCreateFromFields( organization_properties) # Create a user for all roles except sponsor email = "*****@*****.**" account = users.User(email=email) link_id = 'a_role_user' name = 'A Role User' properties = { 'account': account, 'link_id': link_id, 'name': name, } key_name = user_logic.getKeyNameFromFields(properties) role_user = user_logic.updateOrCreateFromKeyName(properties, key_name) # Create an admin for an_org gsoc_org_admin_properties = { 'link_id': 'an_org_admin', 'given_name': 'A', 'surname': 'Orgadmin', 'scope_path': organization.scope_path + '/' + organization.link_id, 'scope': organization, 'program': program, 'phone': '1-555-2222', 'email': '*****@*****.**', 'res_country': 'United States', 'res_city': 'A City', 'res_street': 'A Street', 'res_postalcode': '12345', 'birth_date': db.DateProperty.now(), 'user': role_user, } gsoc_org_admin_logic.updateOrCreateFromFields(gsoc_org_admin_properties) # Create a mentor for an_org mentor_properties = gsoc_org_admin_properties.copy() mentor_properties.update({ 'link_id': 'a_mentor', 'given_name': 'A', 'surname': 'Mentor', 'email': '*****@*****.**', }) mentor = mentor_logic.updateOrCreateFromFields(mentor_properties) self.mentor = mentor # Create students for a_program student_properties = gsoc_org_admin_properties.copy() student_properties.update({ 'scope_path': program.scope_path + '/' + program.link_id, 'scope': program, 'program': program, 'given_name': 'A', 'surname': 'Student', 'major': 'A Major', 'name_on_documents': 'A Name on Documents', 'publish_location': True, 'blog': 'http://www.ablog.com/', 'home_page': 'http://www.ahomepage.com/', 'photo_url': 'http://www.astudent.com/aphoto.png', 'expected_graduation': 2011, 'school_country': 'United States', 'school_name': 'A School', 'tshirt_size': 'XS', 'tshirt_style': 'male', 'degree': 'Undergraduate', 'phone': '1650253000', 'can_we_contact_you': True, 'program_knowledge': 'I heard about this program through a friend.' }) # Create projects for a_program, an_org and a_mentor project_properties = { 'scope_path': organization.scope_path + '/' + organization.link_id, 'scope': organization, 'title': 'test project', 'abstract': 'test abstract', 'status': 'accepted', 'mentor': mentor, 'program': program, } #The string order of students' link_id is the same with that of students #in the array in order to make sure the last student is handled last size = DEF_BATCH_SIZE num_digits = 0 while True: size /= 10 num_digits += 1 if size == 0: break students, projects = [], [] for i in xrange(DEF_BATCH_SIZE+1): student_link_id = ('student%0'+str(num_digits)+'d') % i student_properties.update({ 'link_id': student_link_id, 'email': student_link_id + '@email.com', }) student = student_logic.updateOrCreateFromFields(student_properties) students.append(student) project_link_id = ('project%0'+str(num_digits)+'d') % i project_properties.update({ 'link_id': project_link_id, 'student': student, }) project = student_project_logic.updateOrCreateFromFields( project_properties) projects.append(project) self.students = students self.projects = projects # Create a project survey for a_program link_id = 'a_project_survey' fields = {'SelectionQ': [u'SelectionQ Option 2 for %s' % link_id, u'SelectionQ Option 1 for %s' % link_id ], 'PickMultipleQ': ['PickMultipleQ Checkbox 1 for %s' % link_id, 'PickMultipleQ Checkbox 2 for %s' % link_id, ], 'LongQ': 'LongQ Custom Prompt for %s' % link_id, 'ShortQ': 'ShortQ Custom Prompt for %s' % link_id, } schema = {u'PickMultipleQ': {'index': 5, 'type': 'pick_multi', 'render': 'multi_checkbox'}, u'LongQ': {'index': 2, 'type': 'long_answer'}, u'ShortQ': {'index': 3, 'type': 'short_answer'}, u'SelectionQ': {'index': 4, 'type': 'selection', 'render': 'single_select'} } survey_properties = { 'link_id': link_id, 'scope_path': program.scope_path + '/' + program.link_id, 'scope': None, 'prefix': 'program', 'author': role_user, 'title': 'A Project Survey', 'short_name': 'APS', 'modified_by': role_user, 'is_featured': True, 'fields': fields, 'schema': schema, 'deadline': datetime.datetime.now() + datetime.timedelta(10), 'taking_access': 'student', } project_survey = project_survey_logic.updateOrCreateFromFields( survey_properties) self.project_survey = project_survey # Create a grading survey for a_program link_id = 'a_grading_survey' survey_properties.update({ 'link_id': link_id, 'title': 'A Grading Survey', 'short_name': 'AGS', 'taking_access': 'mentor', }) grading_survey = grading_survey_logic.updateOrCreateFromFields( survey_properties) self.grading_survey = grading_survey # Create a survey group for a_grading_survey and a_project_survey # of a_program survey_group_properties = { 'link_id': link_id, 'scope_path': program.scope_path + '/' + program.link_id, 'scope': program, 'name': 'A Survey Group', 'grading_survey': grading_survey, 'student_survey': project_survey, } survey_group = survey_group_logic.updateOrCreateFromFields( survey_group_properties) self.survey_group = survey_group
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': self.sponsor.key().id_or_name(), '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 org admin who is also the founder of the org email = '*****@*****.**' account = users.User(email=email) link_id = 'an_oa_user' name = 'An Org Admin User' oa_user_properties = { 'account': account, 'link_id': link_id, 'name': name, 'agreed_to_tos': True, } self.oa_user = user_logic.updateOrCreateFromFields(oa_user_properties) # create an org for the program org_properties = { 'link_id': 'an_org', 'scope': self.program, 'scope_path': self.program.key().id_or_name(), 'name': 'An Organization', 'short_name': 'An Org', 'founder': self.oa_user, 'home_page': 'http://anorg.com', 'email': '*****@*****.**', 'description': 'An Organization Description', 'contact_street': 'An Organization Street', 'contact_city': 'An Organization City', 'contact_country': 'United Kingdom', 'contact_postalcode': '0123456 AnO', 'phone': '1-555-BANANA', 'status': 'active', } self.org = org_logic.updateOrCreateFromFields(org_properties) request_properties = { 'role': 'gsoc_org_admin', 'user': self.oa_user, 'group': self.org, 'message': 'An Invitation Request Message', 'status': 'group_accepted', } self.request = request_logic.updateOrCreateFromFields( request_properties) # Create another user for second org admin who will be the backup admin email = '*****@*****.**' account = users.User(email=email) link_id = 'another_oa_user' name = 'Another Org Admin User' oa_user_properties = { 'account': account, 'link_id': link_id, 'name': name, 'agreed_to_tos': True, } self.another_oa_user = user_logic.updateOrCreateFromFields( oa_user_properties) request_properties = { 'role': 'gsoc_org_admin', 'user': self.another_oa_user, 'group': self.org, 'message': 'An Invitation Request Message', 'status': 'group_accepted', } self.another_request = request_logic.updateOrCreateFromFields( request_properties) # Create a user for third org admin email = '*****@*****.**' account = users.User(email=email) link_id = 'third_oa_user' name = 'Third Org Admin User' oa_user_properties = { 'account': account, 'link_id': link_id, 'name': name, 'agreed_to_tos': True, } self.third_oa_user = user_logic.updateOrCreateFromFields( oa_user_properties) request_properties = { 'role': 'gsoc_org_admin', 'user': self.third_oa_user, 'group': self.org, 'message': 'An Invitation Request Message', 'status': 'group_accepted', } self.third_request = request_logic.updateOrCreateFromFields( request_properties)
def setUp(self): """Set up required for the view tests. """ # Ensure that current user with developer privilege is created user_properties = { 'account': users.get_current_user(), 'link_id': 'current_user', 'name': 'Current User', 'is_developer': True, } user_logic.updateOrCreateFromFields(user_properties) # Create a user for the founder of sponsor email = "*****@*****.**" account = users.User(email=email) link_id = 'a_user' name = 'A User' sponsor_user_properties = { 'account': account, 'link_id': link_id, 'name': name, } sponsor_user = user_logic.updateOrCreateFromFields( sponsor_user_properties) # Create sponsor link_id = 'a_sponsor' name = link_id founder = 'a_founder' 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': sponsor_user, 'phone': phone, 'description': description, 'contact_country': contact_country, 'contact_city': 'A City', 'contact_street': 'A Street', 'contact_postalcode': contact_postalcode, 'home_page': home_page, 'email': email, 'status': 'active', } sponsor = sponsor_logic.updateOrCreateFromFields(sponsor_properties) # Create a timeline for a program timeline_properties = { 'link_id': 'a_program', 'scope_path': 'a_sponsor', 'scope': sponsor, } timeline = timeline_logic.updateOrCreateFromFields(timeline_properties) # Create a program for a_sponsor program_properties = { 'link_id': 'a_program', 'scope': 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, 'allocations_visible': True, 'timeline': timeline, 'status': 'visible', } # GSoC program logic does not work: error in updatePredefinedOrgTags from soc.modules.gsoc.models.program import GSoCProgram program = GSoCProgram(**program_properties) program.put() # Create an organization for a_program organization_properties = { 'link_id': 'an_org', 'name': 'An Organization', 'short_name': 'AO', 'scope_path': 'a_sponsor/a_program', 'scope': program, 'founder': sponsor_user, 'home_page': 'http://www.an_org.com', 'phone': '1-555-2222', 'description': 'An Organization', 'license_name': 'Apache License', 'ideas': 'http://www.an_org.com/ideas', 'contact_country': contact_country, 'contact_city': 'A City', 'contact_street': 'A Street', 'contact_postalcode': contact_postalcode, 'home_page': home_page, 'email': email, 'status': 'active', } organization = gsoc_organization_logic.updateOrCreateFromFields( organization_properties) self.scope_path = organization.scope_path self.link_id = organization.link_id
def createOrgAdminUserForAnotherOrg(self, with_oa_entity=False): """Create another organization, user and invitation for the user """ # Create a user for org admin who is also the founder of the another_org email = '*****@*****.**' account = users.User(email=email) link_id = 'another_org_oa_user' name = 'Another Org Org Admin User' oa_user_properties = { 'account': account, 'link_id': link_id, 'name': name, 'agreed_to_tos': True, } self.another_org_oa_user = user_logic.updateOrCreateFromFields( oa_user_properties) # create another org for the program org_properties = { 'link_id': 'another_org', 'scope': self.program, 'scope_path': self.program.key().id_or_name(), 'name': 'Another Organization', 'short_name': 'Another Org' , 'founder': self.another_org_oa_user, 'home_page': 'http://anotherorg.com', 'email': '*****@*****.**', 'description': 'Another Organization Description', 'contact_street': 'Another Organization Street', 'contact_city': 'Another Organization City', 'contact_country': 'Sweden', 'contact_postalcode': '5653276 NG', 'phone': '61-434-BLUE', 'status': 'active', } self.another_org = org_logic.updateOrCreateFromFields(org_properties) request_properties = { 'role': 'gsoc_org_admin', 'user': self.another_org_oa_user, 'group': self.another_org, 'message': 'An Invitation Request Message', 'status': 'group_accepted', } self.another_org_request = request_logic.updateOrCreateFromFields( request_properties) if with_oa_entity: # create a second org admin role for the second org admin user oa_properties = { 'link_id': 'another_org_org_admin', 'scope_path': self.another_org.key().id_or_name(), 'scope': self.another_org, 'program': self.program, 'user' : self.another_org_oa_user, 'given_name': 'AnotherOrgOrgAdmin', 'surname': 'AnotherOrgAdministrator', 'name_on_documents': 'AnotherOrgOrgAdmin Administrator', 'birth_date': datetime.date(1975, 12, 15), 'email': '*****@*****.**', 'res_street': 'Another Org Admin Street', 'res_city': 'Another Org Admin City', 'res_state': 'Another Org Admin State', 'res_country': 'Netherlands', 'res_postalcode': '572461', 'phone': '72-534-COLORLESS', 'agreed_to_tos': True, } # create the org_admin_entity self.another_org_oa = gsoc_oa_logic.updateOrCreateFromFields( oa_properties) # Create an user for second org admin for another org email = '*****@*****.**' account = users.User(email=email) link_id = 'another_org_another_oa_user' name = 'Another Org Admin User' oa_user_properties = { 'account': account, 'link_id': link_id, 'name': name, 'agreed_to_tos': True, } self.another_org_oa_user = user_logic.updateOrCreateFromFields( oa_user_properties) request_properties = { 'role': 'gsoc_org_admin', 'user': self.another_org_oa_user, 'group': self.another_org, 'message': 'An Invitation Request Message', 'status': 'group_accepted', } self.another_org_second_request = request_logic.updateOrCreateFromFields( request_properties)
def setUp(self): """Set up required for the view tests. """ # Setup TaskQueueTestCase and MailTestCase first super(ProposalDuplicatesTest, self).setUp() # Create a user for the founder of 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, } sponsor_user = user_logic.updateOrCreateFromFields(sponsor_user_properties) # Create a sponsor link_id = 'a_sponsor' name = link_id founder = 'a_founder' 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': sponsor_user, 'phone': phone, 'description': description, 'contact_country': contact_country, 'contact_city': 'A City', 'contact_street': 'A Street', 'contact_postalcode': contact_postalcode, 'home_page': home_page, 'email': email, 'status': 'active', } sponsor = sponsor_logic.updateOrCreateFromFields(sponsor_properties) # Create a timeline for a program timeline_properties = { 'link_id': 'a_program', 'scope_path': 'a_sponsor', 'scope': sponsor, 'accepted_students_announced_deadline': datetime.datetime.now() \ + datetime.timedelta(10) } timeline = gsoc_timeline_logic.updateOrCreateFromFields(timeline_properties) # Create a program for a_sponsor program_properties = { 'key_name': 'a_sponsor/a_program', 'link_id': 'a_program', 'scope': 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, 'allocations_visible': True, 'timeline': timeline, 'status': 'visible', } # GSoC program logic does not work: error in updatePredefinedOrgTags from soc.modules.gsoc.models.program import GSoCProgram program = GSoCProgram(**program_properties) program.put() self.program = program # Create an organization for a_program organization_properties = { 'link_id': 'an_org', 'name': 'An Organization', 'short_name': 'AO', 'scope_path': 'a_sponsor/a_program', 'scope': program, 'founder': sponsor_user, 'home_page': 'http://www.an_org.com', 'phone': '1-555-2222', 'description': 'An Organization', 'license_name': 'Apache License', 'ideas': 'http://www.an_org.com/ideas', 'contact_country': contact_country, 'contact_city': 'A City', 'contact_street': 'A Street', 'contact_postalcode': contact_postalcode, 'home_page': home_page, 'email': email, 'slots': 5, 'status': 'active', } organization = gsoc_organization_logic.updateOrCreateFromFields( organization_properties) self.organization = organization # Create another organization organization_properties.update({ 'link_id': 'another_org', }) another_organization = gsoc_organization_logic.updateOrCreateFromFields( organization_properties) # Create an organization to serve as cursor sub for a_program, which should # come as the first result of query organization_properties.update({ 'link_id': 'aa_org', }) stub_organization = gsoc_organization_logic.updateOrCreateFromFields( organization_properties) # Create a user for all roles except sponsor email = "*****@*****.**" account = users.User(email=email) link_id = 'a_role_user' name = 'A Role User' properties = { 'account': account, 'link_id': link_id, 'name': name, } key_name = user_logic.getKeyNameFromFields(properties) role_user = user_logic.updateOrCreateFromKeyName(properties, key_name) # Create a mentor for an_org mentor_properties = sponsor_properties.copy() mentor_properties.update({ 'link_id': 'a_mentor', 'scope_path': organization.scope_path + '/' + organization.link_id, 'scope': organization, 'program': program, 'given_name': 'A', 'surname': 'Mentor', 'res_country': 'United States', 'res_city': 'A City', 'res_street': 'A Street', 'res_postalcode': '12345', 'birth_date': db.DateProperty.now(), 'user': role_user, }) mentor = mentor_logic.updateOrCreateFromFields(mentor_properties) self.mentor = mentor # Create a student for a_program student_properties = mentor_properties.copy() student_properties.update({ 'link_id': 'a_student', 'scope_path': program.scope_path + '/' + program.link_id, 'scope': program, 'program': program, 'given_name': 'A', 'surname': 'Student', 'major': 'A Major', 'name_on_documents': 'A Name on Documents', 'publish_location': True, 'blog': 'http://www.ablog.com/', 'home_page': 'http://www.ahomepage.com/', 'photo_url': 'http://www.astudent.com/aphoto.png', 'expected_graduation': 2011, 'school_country': 'United States', 'school_name': 'A School', 'tshirt_size': 'XS', 'tshirt_style': 'male', 'degree': 'Undergraduate', 'phone': '1650253000', 'can_we_contact_you': True, 'program_knowledge': 'I heard about this program through a friend.' }) student = student_logic.updateOrCreateFromFields(student_properties) self.student = student # Create a student proposal to an_org for a_student student_proposal_properties = { 'link_id': 'a_proposal', 'scope_path': student.scope_path + '/' + student.link_id, 'scope': student, 'title': 'A Proposal Title', 'abstract': 'A Proposal Abstract', 'content': 'A Proposal Content', 'additional_info': 'http://www.a_proposal.com', 'mentor': mentor, 'status': 'pending', 'org': organization, 'program': program, } self.student_proposal = student_proposal_logic.updateOrCreateFromFields( student_proposal_properties) # Create another student proposal to an_org for a_student student_proposal_properties.update({ 'link_id': 'another_proposal', }) student_proposal_logic.updateOrCreateFromFields(student_proposal_properties) # Create the third student proposal to another_org for a_student student_proposal_properties.update({ 'link_id': 'third_proposal', 'org': another_organization, }) student_proposal_logic.updateOrCreateFromFields(student_proposal_properties)
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': self.sponsor.key().id_or_name(), '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 org admin who is also the founder of the org email = '*****@*****.**' account = users.User(email=email) link_id = 'an_org_admin_user' name = 'An Org Admin User' org_admin_user_properties = { 'account': account, 'link_id': link_id, 'name': name, } self.org_admin_user = user_logic.updateOrCreateFromFields( org_admin_user_properties) # create an org for the program org_properties = { 'link_id': 'an_org', 'scope': self.program, 'scope_path': self.program.key().id_or_name(), 'name': 'An Organization', 'short_name': 'An Org' , 'founder': self.org_admin_user, 'home_page': 'http://anorg.com', 'email': '*****@*****.**', 'description': 'An Organization Description', 'contact_street': 'An Organization Street', 'contact_city': 'An Organization City', 'contact_country': 'United Kingdom', 'contact_postalcode': '0123456 AnO', 'phone': '1-555-BANANA', 'status': 'active', } self.org = org_logic.updateOrCreateFromFields(org_properties) # Create an org admin role for a_user org_admin_properties = { 'link_id': 'an_org_admin', 'scope_path': self.org.key().id_or_name(), 'scope': self.org, 'program': self.program, 'user' : self.org_admin_user, 'given_name': 'OrgAdmin', 'surname': 'Administrator', 'name_on_documents': 'OrgAdmin Administrator', 'birth_date': datetime.date(1970, 1, 1), 'email': '*****@*****.**', 'res_street': 'An Org Admin Street', 'res_city': 'An Org Admin City', 'res_state': 'An Org Admin State', 'res_country': 'France', 'res_postalcode': '12345', 'phone': '1-555-BANANA', 'agreed_to_tos': True, } # create the org_admin_entity self.org_admin = org_admin_logic.updateOrCreateFromFields( org_admin_properties) self.scope_path = self.org_admin.scope_path self.link_id = self.org_admin.link_id
def setUp(self): """Set up required for the task tests. """ # Setup TaskQueueTestCase and MailTestCase first super(AcceptProposalsTest, self).setUp() # Create a user for the founder of 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, } sponsor_user = user_logic.updateOrCreateFromFields( sponsor_user_properties) # Create a sponsor link_id = 'a_sponsor' name = link_id founder = 'a_founder' 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': sponsor_user, 'phone': phone, 'description': description, 'contact_country': contact_country, 'contact_city': 'A City', 'contact_street': 'A Street', 'contact_postalcode': contact_postalcode, 'home_page': home_page, 'email': email, 'status': 'active', } sponsor = sponsor_logic.updateOrCreateFromFields(sponsor_properties) # Create a timeline for a program timeline_properties = { 'link_id': 'a_program', 'scope_path': 'a_sponsor', 'scope': sponsor, 'accepted_students_announced_deadline': datetime.datetime.now() \ + datetime.timedelta(10) } timeline = gsoc_timeline_logic.updateOrCreateFromFields( timeline_properties) # Create a program for a_sponsor program_properties = { 'key_name': 'a_sponsor/a_program', 'link_id': 'a_program', 'scope': 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, 'allocations_visible': True, 'timeline': timeline, 'status': 'visible', } # GSoC program logic does not work: error in updatePredefinedOrgTags from soc.modules.gsoc.models.program import GSoCProgram program = GSoCProgram(**program_properties) program.put() self.program = program # Create an organization for a_program organization_properties = { 'link_id': 'an_org', 'name': 'An Organization', 'short_name': 'AO', 'scope_path': 'a_sponsor/a_program', 'scope': program, 'founder': sponsor_user, 'home_page': 'http://www.an_org.com', 'phone': '1-555-2222', 'description': 'An Organization', 'license_name': 'Apache License', 'ideas': 'http://www.an_org.com/ideas', 'contact_country': contact_country, 'contact_city': 'A City', 'contact_street': 'A Street', 'contact_postalcode': contact_postalcode, 'home_page': home_page, 'email': email, 'slots': 1, 'status': 'active', } organization = gsoc_organization_logic.updateOrCreateFromFields( organization_properties) self.organization = organization # Create another organization for a_program organization_properties.update({ 'link_id': 'another_org', }) another_organization = gsoc_organization_logic.updateOrCreateFromFields( organization_properties) # Create an organization to serve as cursor sub for a_program, which should # come as the first result of query organization_properties.update({ 'link_id': 'aa_org', }) stub_organization = gsoc_organization_logic.updateOrCreateFromFields( organization_properties) self.stub_organization = stub_organization # Create a user for all roles except sponsor email = "*****@*****.**" account = users.User(email=email) link_id = 'a_role_user' name = 'A Role User' properties = { 'account': account, 'link_id': link_id, 'name': name, } key_name = user_logic.getKeyNameFromFields(properties) role_user = user_logic.updateOrCreateFromKeyName(properties, key_name) # Create a mentor for an_org mentor_properties = sponsor_properties.copy() mentor_properties.update({ 'link_id': 'a_mentor', 'scope_path': organization.scope_path + '/' + organization.link_id, 'scope': organization, 'program': program, 'given_name': 'A', 'surname': 'Mentor', 'res_country': 'United States', 'res_city': 'A City', 'res_street': 'A Street', 'res_postalcode': '12345', 'birth_date': db.DateProperty.now(), 'user': role_user, 'email': '*****@*****.**', }) mentor = mentor_logic.updateOrCreateFromFields(mentor_properties) self.mentor = mentor # Create a student for a_program student_properties = mentor_properties.copy() student_properties.update({ 'link_id': 'a_student', 'scope_path': program.scope_path + '/' + program.link_id, 'scope': program, 'program': program, 'given_name': 'A', 'surname': 'Student', 'major': 'A Major', 'name_on_documents': 'A Name on Documents', 'publish_location': True, 'blog': 'http://www.ablog.com/', 'home_page': 'http://www.ahomepage.com/', 'email': '*****@*****.**', 'photo_url': 'http://www.astudent.com/aphoto.png', 'expected_graduation': 2011, 'school_country': 'United States', 'school_name': 'A School', 'tshirt_size': 'XS', 'tshirt_style': 'male', 'degree': 'Undergraduate', 'phone': '1650253000', 'can_we_contact_you': True, 'program_knowledge': 'I heard about this program through a friend.' }) student = student_logic.updateOrCreateFromFields(student_properties) self.student = student # Create another student for a_program student_properties.update({ 'link_id': 'another_student', 'email': '*****@*****.**', }) another_student = student_logic.updateOrCreateFromFields( student_properties) self.another_student = another_student # Create a third student for a_program student_properties.update({ 'link_id': 'third_student', 'email': '*****@*****.**', }) third_student = student_logic.updateOrCreateFromFields( student_properties) self.third_student = third_student # Create a student proposal to an_org for a_student student_proposal_properties = { 'link_id': 'a_proposal', 'scope_path': student.scope_path + '/' + student.link_id, 'scope': student, 'title': 'A Proposal Title', 'abstract': 'A Proposal Abstract', 'content': 'A Proposal Content', 'additional_info': 'http://www.a_proposal.com', 'mentor': mentor, 'status': 'pending', 'org': organization, 'program': program, 'score': 90, } self.proposal = student_proposal_logic.updateOrCreateFromFields( student_proposal_properties) # Create another student proposal to an_org for another_student student_proposal_properties.update({ 'link_id': 'another_proposal', 'scope_path': another_student.scope_path + '/' + another_student.link_id, 'scope': another_student, 'score': 100, }) self.another_proposal = student_proposal_logic.updateOrCreateFromFields( student_proposal_properties) # Create a third student proposal to another_org for third_student student_proposal_properties.update({ 'link_id': 'third_proposal', 'scope_path': third_student.scope_path + '/' + third_student.link_id, 'scope': third_student, 'org': another_organization, 'score': 10, }) student_proposal_logic.updateOrCreateFromFields( student_proposal_properties)
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. """ # Ensure that current user with developer privilege is created user_properties = { 'account': users.get_current_user(), 'link_id': 'current_user', 'name': 'Current User', 'is_developer': True, } user_logic.updateOrCreateFromFields(user_properties) # Create a user for the founder of sponsor email = "*****@*****.**" account = users.User(email=email) link_id = 'a_user' name = 'A User' sponsor_user_properties = { 'account': account, 'link_id': link_id, 'name': name, } sponsor_user = user_logic.updateOrCreateFromFields(sponsor_user_properties) # Create sponsor link_id = 'a_sponsor' name = link_id founder = 'a_founder' 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': sponsor_user, 'phone': phone, 'description': description, 'contact_country': contact_country, 'contact_city': 'A City', 'contact_street': 'A Street', 'contact_postalcode': contact_postalcode, 'home_page': home_page, 'email': email, 'status': 'active', } sponsor = sponsor_logic.updateOrCreateFromFields(sponsor_properties) # Create a timeline for a program timeline_properties = { 'link_id': 'a_program', 'scope_path': 'a_sponsor', 'scope': sponsor, } timeline = timeline_logic.updateOrCreateFromFields(timeline_properties) # Create a program for a_sponsor program_properties = { 'link_id': 'a_program', 'scope': 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, 'allocations_visible': True, 'timeline': timeline, 'status': 'visible', } # GSoC program logic does not work: error in updatePredefinedOrgTags from soc.modules.gsoc.models.program import GSoCProgram program = GSoCProgram(**program_properties) program.put() # Create an organization for a_program organization_properties = { 'link_id': 'an_org', 'name': 'An Organization', 'short_name': 'AO', 'scope_path': 'a_sponsor/a_program', 'scope': program, 'founder': sponsor_user, 'home_page': 'http://www.an_org.com', 'phone': '1-555-2222', 'description': 'An Organization', 'license_name': 'Apache License', 'ideas': 'http://www.an_org.com/ideas', 'contact_country': contact_country, 'contact_city': 'A City', 'contact_street': 'A Street', 'contact_postalcode': contact_postalcode, 'home_page': home_page, 'email': email, 'status': 'active', } organization = gsoc_organization_logic.updateOrCreateFromFields( organization_properties) self.scope_path = organization.scope_path self.link_id = organization.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': self.sponsor.key().id_or_name(), '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 org admin who is also the founder of the org email = '*****@*****.**' account = users.User(email=email) link_id = 'an_oa_user' name = 'An Org Admin User' oa_user_properties = { 'account': account, 'link_id': link_id, 'name': name, 'agreed_to_tos': True, } self.oa_user = user_logic.updateOrCreateFromFields( oa_user_properties) # create an org for the program org_properties = { 'link_id': 'an_org', 'scope': self.program, 'scope_path': self.program.key().id_or_name(), 'name': 'An Organization', 'short_name': 'An Org' , 'founder': self.oa_user, 'home_page': 'http://anorg.com', 'email': '*****@*****.**', 'description': 'An Organization Description', 'contact_street': 'An Organization Street', 'contact_city': 'An Organization City', 'contact_country': 'United Kingdom', 'contact_postalcode': '0123456 AnO', 'phone': '1-555-BANANA', 'status': 'active', } self.org = org_logic.updateOrCreateFromFields(org_properties) request_properties = { 'role': 'gsoc_org_admin', 'user': self.oa_user, 'group': self.org, 'message': 'An Invitation Request Message', 'status': 'group_accepted', } self.request = request_logic.updateOrCreateFromFields(request_properties) # Create another user for second org admin who will be the backup admin email = '*****@*****.**' account = users.User(email=email) link_id = 'another_oa_user' name = 'Another Org Admin User' oa_user_properties = { 'account': account, 'link_id': link_id, 'name': name, 'agreed_to_tos': True, } self.another_oa_user = user_logic.updateOrCreateFromFields( oa_user_properties) request_properties = { 'role': 'gsoc_org_admin', 'user': self.another_oa_user, 'group': self.org, 'message': 'An Invitation Request Message', 'status': 'group_accepted', } self.another_request = request_logic.updateOrCreateFromFields( request_properties) # Create a user for third org admin email = '*****@*****.**' account = users.User(email=email) link_id = 'third_oa_user' name = 'Third Org Admin User' oa_user_properties = { 'account': account, 'link_id': link_id, 'name': name, 'agreed_to_tos': True, } self.third_oa_user = user_logic.updateOrCreateFromFields( oa_user_properties) request_properties = { 'role': 'gsoc_org_admin', 'user': self.third_oa_user, 'group': self.org, 'message': 'An Invitation Request Message', 'status': 'group_accepted', } self.third_request = request_logic.updateOrCreateFromFields( request_properties)