Пример #1
0
 def setUp(self):
     """Set up required for the view tests.
 """
     # Ensure that the current user with developer/admin privilege is created
     properties = {
         'account': users.get_current_user(),
         'link_id': 'current_user',
         'name': 'Current User',
         'is_developer': True,
     }
     key_name = user_logic.getKeyNameFromFields(properties)
     self.entity = user_logic.updateOrCreateFromKeyName(
         properties, key_name)
     # Create another user
     email = "*****@*****.**"
     account = users.User(email=email)
     link_id = 'another_user'
     name = 'Another User'
     properties = {
         'account': account,
         'link_id': link_id,
         'name': name,
     }
     key_name = user_logic.getKeyNameFromFields(properties)
     self.another_entity = user_logic.updateOrCreateFromKeyName(
         properties, key_name)
Пример #2
0
 def setUp(self):
   """Set up required for the view tests.
   """
   # Ensure that current user is created
   properties = {
       'account': users.get_current_user(),
       'link_id': 'current_user',
       'name': 'Current User',
       'is_developer': True,
       }
   key_name = user_logic.getKeyNameFromFields(properties)
   self.user = user_logic.updateOrCreateFromKeyName(properties, key_name)
   # Create another user
   email = "*****@*****.**"
   account = users.User(email=email)
   link_id = 'another_user'
   name = 'Another User'
   properties = {
       'account': account,
       'link_id': link_id,
       'name': name,
       }
   key_name = user_logic.getKeyNameFromFields(properties)
   self.another_user = user_logic.updateOrCreateFromKeyName(properties,
                                                            key_name)
Пример #3
0
    def testCapsAuthEntity(self):
        """
    """

        # create a user from the auth domain
        email = "*****@*****.**"
        account = users.User(email=email)
        link_id = 'caps_user'
        name = 'Caps User'

        properties = {
            'account': account,
            'link_id': link_id,
            'name': name,
        }

        key_name = user_logic.getKeyNameFromFields(properties)
        entity = user_logic.updateOrCreateFromKeyName(properties, key_name)

        self.failIfEqual(account, entity.account)
        self.failUnlessEqual('*****@*****.**', entity.account.email())
        self.failUnlessEqual(link_id, entity.link_id)
        self.failUnlessEqual(name, entity.name)

        denormalized = accounts.denormalizeAccount(entity.account)
        self.failUnlessEqual(account.email().lower(), denormalized.email())
Пример #4
0
  def testAuthEntity(self):
    """
    """

    # create a user from the auth domain
    email = "*****@*****.**"
    account = users.User(email=email)
    link_id = 'auth_user'
    name = 'Auth User'

    properties = {
        'account': account,
        'link_id': link_id,
        'name': name,
        }

    key_name = user_logic.getKeyNameFromFields(properties)
    entity = user_logic.updateOrCreateFromKeyName(properties, key_name)

    self.failIfEqual(account, entity.account)
    self.failUnlessEqual('test', entity.account.email())
    self.failUnlessEqual(link_id, entity.link_id)
    self.failUnlessEqual(name, entity.name)

    denormalized = accounts.denormalizeAccount(entity.account)
    self.failUnlessEqual(account.email().lower(), denormalized.email())
Пример #5
0
    def setUp(self):
        """Set up required for the slot allocation tests.
    """

        # ensure that current user is created
        properties = {
            'account': users.get_current_user(),
            'link_id': 'current_user',
            'name': 'Current User',
        }

        key_name = user_logic.getKeyNameFromFields(properties)
        user_logic.updateOrCreateFromKeyName(properties, key_name)
Пример #6
0
  def setUp(self):
    """Set up required for the slot allocation tests.
    """

    # ensure that current user is created
    properties = {
        'account': users.get_current_user(),
        'link_id': 'current_user',
        'name': 'Current User',
        }

    key_name = user_logic.getKeyNameFromFields(properties)
    user_logic.updateOrCreateFromKeyName(properties, key_name)
Пример #7
0
 def setUp(self):
   """Set up required for the view tests.
   """
   # Create a user
   email = "*****@*****.**"
   account = users.User(email=email)
   link_id = 'a_user'
   name = 'A User'
   properties = {
       'account': account,
       'link_id': link_id,
       'name': name,
       }
   key_name = user_logic.getKeyNameFromFields(properties)
   self.entity = user_logic.updateOrCreateFromKeyName(properties, key_name)
Пример #8
0
 def setUp(self):
     """Set up required for the view tests.
 """
     # Create a user
     email = "*****@*****.**"
     account = users.User(email=email)
     link_id = 'a_user'
     name = 'A User'
     properties = {
         'account': account,
         'link_id': link_id,
         'name': name,
     }
     key_name = user_logic.getKeyNameFromFields(properties)
     self.entity = user_logic.updateOrCreateFromKeyName(
         properties, key_name)
Пример #9
0
  def setUp(self):
    """Set up required for sample feed item test. 
    
    Creates sender, receiver, and user entities required for news_feed
    test. 
    """

    # ensure that current user is created
    properties = {
        'account': users.get_current_user(),
        'link_id': 'current_user',
        'name': 'Current User',
        }

    key_name = user_logic.getKeyNameFromFields(properties)
    self.user = user_logic.updateOrCreateFromKeyName(properties, key_name)

    site_properties = {
      'key_name': 'site',
      'link_id': 'site',
      }

    key_name = site_logic.getKeyNameFromFields(site_properties)
    self.site = site_logic.updateOrCreateFromKeyName(
    site_properties, key_name)
        
    document_properties = {
      'key_name': 'site/site/home',
      'link_id': 'home',
      'scope_path': 'site',
      'scope': self.site,
      'prefix': 'site',
      'author': self.user,
      'title': 'Home Page',
      'short_name': 'Home',
      'content': 'This is the Home Page',
      'modified_by': self.user,
      }

    key_name = document_logic.getKeyNameFromFields(document_properties)
    self.document = document_logic.updateOrCreateFromKeyName(
    document_properties, key_name)
Пример #10
0
 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)
Пример #11
0
 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)
Пример #12
0
 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.
   """
   # 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