def test001MethodsForEmaillist(self):
    
    user_name = 'YujiMatsuo-' + self.postfix
    family_name = 'Matsuo'
    given_name = 'Yuji'
    password = '123$$abc'
    suspended = 'false'

    try:
      user_yuji = self.apps_client.CreateUser(
        user_name=user_name, family_name=family_name, given_name=given_name,
        password=password, suspended=suspended)
    except Exception, e:
      self.fail('Unexpected exception occurred: %s' % e)

    self.created_users.append(user_yuji)

    user_name = 'TaroMatsuo-' + self.postfix
    family_name = 'Matsuo'
    given_name = 'Taro'
    password = '123$$abc'
    suspended = 'false'

    try:
      user_taro = self.apps_client.CreateUser(
        user_name=user_name, family_name=family_name, given_name=given_name,
        password=password, suspended=suspended)
    except Exception, e:
      self.fail('Unexpected exception occurred: %s' % e)

    self.created_users.append(user_taro)

    # tests CreateEmailList method
    list_name = 'list01-' + self.postfix
    try:
      created_email_list = self.apps_client.CreateEmailList(list_name)
    except Exception, e:
      self.fail('Unexpected exception occurred: %s' % e)

    self.assert_(isinstance(created_email_list, gdata.apps.EmailListEntry),
        "Return value of CreateEmailList method must be an instance of " +
        "EmailListEntry: %s" % created_email_list)
    self.assertEquals(created_email_list.email_list.name, list_name)
    self.created_email_lists.append(created_email_list)

    # tests AddRecipientToEmailList method
    try:
      recipient = self.apps_client.AddRecipientToEmailList(
        user_yuji.login.user_name + '@' + apps_domain,
        list_name)
    except Exception, e:
      self.fail('Unexpected exception occurred: %s' % e)

    self.assert_(isinstance(recipient, gdata.apps.EmailListRecipientEntry),
        "Return value of AddRecipientToEmailList method must be an instance " +
        "of EmailListRecipientEntry: %s" % recipient)
    self.assertEquals(recipient.who.email, 
                      user_yuji.login.user_name + '@' + apps_domain)

    try:
      recipient = self.apps_client.AddRecipientToEmailList(
        user_taro.login.user_name + '@' + apps_domain,
        list_name)
    except Exception, e:
      self.fail('Unexpected exception occurred: %s' % e)

    # tests RetrieveAllRecipients method
    try:
      recipient_feed = self.apps_client.RetrieveAllRecipients(list_name)
    except Exception, e:
      self.fail('Unexpected exception occurred: %s' % e)

    self.assert_(isinstance(recipient_feed, gdata.apps.EmailListRecipientFeed),
        "Return value of RetrieveAllRecipients method must be an instance " +
        "of EmailListRecipientFeed: %s" % recipient_feed)
    self.assertEquals(len(recipient_feed.entry), 2)

    # tests RemoveRecipientFromEmailList method
    try:
      self.apps_client.RemoveRecipientFromEmailList(
        user_taro.login.user_name + '@' + apps_domain, list_name)
    except Exception, e:
      self.fail('Unexpected exception occurred: %s' % e)

    # make sure that removal succeeded.
    try:
      recipient_feed = self.apps_client.RetrieveAllRecipients(list_name)
    except Exception, e:
      self.fail('Unexpected exception occurred: %s' % e)

    self.assert_(isinstance(recipient_feed, gdata.apps.EmailListRecipientFeed),
        "Return value of RetrieveAllRecipients method must be an instance " +
        "of EmailListRecipientFeed: %s" % recipient_feed)
    self.assertEquals(len(recipient_feed.entry), 1)

    # tests RetrieveAllEmailLists
    try:
      list_feed = self.apps_client.RetrieveAllEmailLists()
    except Exception, e:
      self.fail('Unexpected exception occurred: %s' % e)
    self.assert_(isinstance(list_feed, gdata.apps.EmailListFeed),
        "Return value of RetrieveAllEmailLists method must be an instance" +
        "of EmailListFeed: %s" % list_feed)
    succeed = False
    for email_list in list_feed.entry:
      if email_list.email_list.name == list_name:
        succeed = True
    self.assert_(succeed, "There must be an email list named %s" % list_name)
    
    # tests RetrieveEmailLists method.
    try:
      list_feed = self.apps_client.RetrieveEmailLists(
        user_yuji.login.user_name + '@' + apps_domain)
    except Exception, e:
      self.fail('Unexpected exception occurred: %s' % e)
    self.assert_(isinstance(list_feed, gdata.apps.EmailListFeed),
        "Return value of RetrieveEmailLists method must be an instance" +
        "of EmailListFeed: %s" % list_feed)
    succeed = False
    for email_list in list_feed.entry:
      if email_list.email_list.name == list_name:
        succeed = True
    self.assert_(succeed, "There must be an email list named %s" % list_name)
Tests methods for emaillist
dataset/ETHPy150Open kuri65536/python-for-android/python-build/python-libs/gdata/tests/gdata_tests/apps/service_test.py/AppsServiceUnitTest02.test001MethodsForEmaillist