def test_low_level_create_update_delete(self):
    if not conf.options.get_value('runlive') == 'true':
      return
    # Either load the recording or prepare to make a live request.
    conf.configure_cache(self.client, 'test_low_level_create_update_delete')
    entry = atom.data.Entry()
    entry.title = atom.data.Title(text='Jeff')
    entry._other_elements.append(
        gdata.data.Email(rel=gdata.data.WORK_REL, address='*****@*****.**'))

    http_request = atom.http_core.HttpRequest()
    http_request.add_body_part(entry.to_string(), 'application/atom+xml')
    posted = self.client.request('POST', 
        'http://www.google.com/m8/feeds/contacts/default/full',
        desired_class=atom.data.Entry, http_request=http_request)

    self_link = None
    edit_link = None
    for link in posted.get_elements('link', 'http://www.w3.org/2005/Atom'):
      if link.get_attributes('rel')[0].value == 'self':
        self_link = link.get_attributes('href')[0].value
      elif link.get_attributes('rel')[0].value == 'edit':
        edit_link = link.get_attributes('href')[0].value
    self.assertTrue(self_link is not None)
    self.assertTrue(edit_link is not None)

    etag = posted.get_attributes('etag')[0].value
    self.assertTrue(etag is not None)
    self.assertTrue(len(etag) > 0)

    # Delete the test contact.
    http_request = atom.http_core.HttpRequest()
    http_request.headers['If-Match'] = etag
    self.client.request('DELETE', edit_link, http_request=http_request)
    def testDataFeed(self):
        """Tests if the Data Feed exists."""

        start_date = "2008-10-01"
        end_date = "2008-10-02"
        metrics = "ga:visits"

        if not conf.options.get_value("runlive") == "true":
            return
        conf.configure_cache(self.client, "testDataFeed")

        data_query = gdata.analytics.client.DataFeedQuery(
            {
                "ids": conf.options.get_value("table_id"),
                "start-date": start_date,
                "end-date": end_date,
                "metrics": metrics,
                "max-results": "1",
            }
        )
        feed = self.client.GetDataFeed(data_query)

        self.assertTrue(feed.entry is not None)
        self.assertEqual(feed.start_date.text, start_date)
        self.assertEqual(feed.end_date.text, end_date)
        self.assertEqual(feed.entry[0].GetMetric(metrics).name, metrics)
Example #3
0
  def test_low_level_create_update_delete(self):
    if not conf.options.get_value('runlive') == 'true':
      return
    # Either load the recording or prepare to make a live request.
    conf.configure_cache(self.client, 'test_low_level_create_update_delete')
    entry = atom.data.Entry()
    entry.title = atom.data.Title(text='Jeff')
    entry._other_elements.append(
        gdata.data.Email(rel=gdata.data.WORK_REL, address='*****@*****.**'))

    http_request = atom.http_core.HttpRequest()
    http_request.add_body_part(entry.to_string(), 'application/atom+xml')
    posted = self.client.request('POST', 
        'http://www.google.com/m8/feeds/contacts/default/full',
        desired_class=atom.data.Entry, http_request=http_request)

    self_link = None
    edit_link = None
    for link in posted.get_elements('link', 'http://www.w3.org/2005/Atom'):
      if link.get_attributes('rel')[0].value == 'self':
        self_link = link.get_attributes('href')[0].value
      elif link.get_attributes('rel')[0].value == 'edit':
        edit_link = link.get_attributes('href')[0].value
    self.assert_(self_link is not None)
    self.assert_(edit_link is not None)

    etag = posted.get_attributes('etag')[0].value
    self.assert_(etag is not None)
    self.assert_(len(etag) > 0)

    # Delete the test contact.
    http_request = atom.http_core.HttpRequest()
    http_request.headers['If-Match'] = etag
    self.client.request('DELETE', edit_link, http_request=http_request)
    def testCreateRetrieveUpdateDelete(self):
        if not conf.options.get_value('runlive') == 'true':
            return

        # Either load the recording or prepare to make a live request.
        conf.configure_cache(self.client, 'testCreateUpdateDelete')

        try:
            new_entry = self.client.CreateResource(
                'CR-NYC-14-12-BR', 'Boardroom',
                ('This conference room is in New York City, building 14, floor 12, '
                 'Boardroom'), 'CR')
        except Exception as e:
            print()
            e
            self.client.delete_resource('CR-NYC-14-12-BR')
            # If the test failed to run to completion
            # the resource may already exist
            new_entry = self.client.CreateResource(
                'CR-NYC-14-12-BR', 'Boardroom',
                ('This conference room is in New York City, building 14, floor 12, '
                 'Boardroom'), 'CR')

        self.assertTrue(
            isinstance(new_entry,
                       gdata.calendar_resource.data.CalendarResourceEntry))
        self.assertEqual(new_entry.resource_id, 'CR-NYC-14-12-BR')
        self.assertEqual(new_entry.resource_common_name, 'Boardroom')
        self.assertEqual(new_entry.resource_description, (
            'This conference room is in New York City, building 14, floor 12, '
            'Boardroom'))
        self.assertEqual(new_entry.resource_type, 'CR')

        fetched_entry = self.client.get_resource(resource_id='CR-NYC-14-12-BR')
        self.assertTrue(
            isinstance(fetched_entry,
                       gdata.calendar_resource.data.CalendarResourceEntry))
        self.assertEqual(fetched_entry.resource_id, 'CR-NYC-14-12-BR')
        self.assertEqual(fetched_entry.resource_common_name, 'Boardroom')
        self.assertEqual(fetched_entry.resource_description, (
            'This conference room is in New York City, building 14, floor 12, '
            'Boardroom'))
        self.assertEqual(fetched_entry.resource_type, 'CR')

        new_entry.resource_id = 'CR-MTV-14-12-BR'
        new_entry.resource_common_name = 'Executive Boardroom'
        new_entry.resource_description = 'This conference room is in Mountain View'
        new_entry.resource_type = 'BR'
        updated_entry = self.client.update(new_entry)
        self.assertTrue(
            isinstance(updated_entry,
                       gdata.calendar_resource.data.CalendarResourceEntry))
        self.assertEqual(updated_entry.resource_id, 'CR-MTV-14-12-BR')
        self.assertEqual(updated_entry.resource_common_name,
                         'Executive Boardroom')
        self.assertEqual(updated_entry.resource_description,
                         'This conference room is in Mountain View')
        self.assertEqual(updated_entry.resource_type, 'BR')

        self.client.delete_resource('CR-NYC-14-12-BR')
    def testAccountFeed(self):
        """Tests if the Account Feed exists."""

        if not conf.options.get_value("runlive") == "true":
            return
        conf.configure_cache(self.client, "testAccountFeed")

        account_query = gdata.analytics.client.AccountFeedQuery({"max-results": "1"})

        feed = self.client.GetAccountFeed(account_query)
        self.assertTrue(feed.entry is not None)

        properties = [
            "ga:accountId",
            "ga:accountName",
            "ga:profileId",
            "ga:webPropertyId",
            "ga:currency",
            "ga:timezone",
        ]

        entry = feed.entry[0]
        for prop in properties:
            property = entry.GetProperty(prop)
            self.assertEqual(property.name, prop)
  def test_create_unlisted_map(self):
    if not conf.options.get_value('runlive') == 'true':
      return
    conf.configure_cache(self.client, 'test_create_unlisted_map')

    # Add an unlisted map.
    created = self.client.create_map('An unlisted test map',
                                     'This should be unlisted.',
                                     unlisted=True)

    self.assertEqual(created.title.text, 'An unlisted test map')
    self.assertEqual(created.summary.text, 'This should be unlisted.')
    self.assert_(created.control is not None)
    self.assert_(created.control.draft is not None)
    self.assertEqual(created.control.draft.text, 'yes')
    
    # Make the map public. 
    created.control.draft.text = 'no'
    updated = self.client.update(created)

    if updated.control is not None and updated.control.draft is not None:
      self.assertNotEqual(updated.control.draft.text, 'yes')
      
    # Delete the test map using the URL instead of the entry.
    self.client.delete(updated.find_edit_link())
  def test_get_comments(self):
    if not conf.options.get_value('runlive') == 'true':
      return
    # Either load the recording or prepare to make a live request.
    conf.configure_cache(self.client, 'test_create_update_delete')

    # Create an issue so we have something to look up.
    created = self.create_issue()

    # The fully qualified id is a url, we just want the number.
    issue_id = created.id.text.split('/')[-1]

    # Now lets add two comments to that issue.
    for i in range(2):
      update_response = self.client.update_issue(
          self.project_name,
          issue_id,
          self.owner,
          comment='My comment here %s' % i)

    # We have an issue that has several comments. Lets get them.
    comments_feed = self.client.get_comments(self.project_name, issue_id)

    # It has 2 comments.
    self.assertEqual(2, len(comments_feed.entry))
  def testGetLicenseNotifications(self):
    if not conf.options.get_value('runlive') == 'true':
      return

    # Either load the recording or prepare to make a live request.
    conf.configure_cache(self.client, 'testGetLicenseNotifications')
    
    fetched_feed = self.client.GetLicenseNotifications(app_id=self.app_id, max_results=2)
    self.assertTrue(isinstance(fetched_feed, gdata.marketplace.data.LicenseFeed))
    self.assertEqual(len(fetched_feed.entry), 2)
    for entry in fetched_feed.entry:
      entity = entry.content.entity
      self.assertTrue(entity is not None)
      self.assertNotEqual(entity.id, '')
      self.assertNotEqual(entity.domain_name, '')
      self.assertNotEqual(entity.installer_email, '')
      self.assertNotEqual(entity.tos_acceptance_time, '')
      self.assertNotEqual(entity.last_change_time, '')
      self.assertNotEqual(entity.product_config_id, '')
      self.assertNotEqual(entity.state, '')
    
    next_uri = fetched_feed.find_next_link()
    fetched_feed_next = self.client.GetLicenseNotifications(uri=next_uri)
    self.assertTrue(isinstance(fetched_feed_next, gdata.marketplace.data.LicenseFeed))
    self.assertTrue(len(fetched_feed_next.entry) <= 2)
    for entry in fetched_feed_next.entry:
      entity = entry.content.entity
      self.assertTrue(entity is not None)
      self.assertNotEqual(entity.id, '')
      self.assertNotEqual(entity.domain_name, '')
      self.assertNotEqual(entity.installer_email, '')
      self.assertNotEqual(entity.tos_acceptance_time, '')
      self.assertNotEqual(entity.last_change_time, '')
      self.assertNotEqual(entity.product_config_id, '')
      self.assertNotEqual(entity.state, '')
Example #9
0
 def test_retrieve_post_with_categories(self):
     if not conf.options.get_value('runlive') == 'true':
         return
     conf.configure_cache(self.client, 'test_retrieve_post_with_categories')
     query = gdata.blogger.client.Query(categories=["news"], strict=True)
     posts = self.client.get_posts(conf.options.get_value('blogid'),
                                   query=query)
Example #10
0
 def test_retrieve_video_entry(self):
   if not conf.options.get_value('runlive') == 'true':
     return
   # Either load the recording or prepare to make a live request.
   conf.configure_cache(self.client, 'test_retrieve_video_entry')
   entry = self.client.get_video_entry(video_id=conf.options.get_value('videoid'))
   self.assertTrue(entry.etag)
Example #11
0
 def setUp(self):
   self.client = None
   if conf.options.get_value('runlive') == 'true':
     self.client = gdata.docs.client.DocsClient()
     self.client.ssl = conf.options.get_value('ssl') == 'true'
     conf.configure_client(self.client, 'DocsTest', self.client.auth_service)
     conf.configure_cache(self.client, 'testDocsRevisions')
     try:
       self.testdoc = self.client.Create(
           gdata.docs.data.DOCUMENT_LABEL, 'My Doc')
       # Because of an etag change issue, we must sleep for a few seconds
       time.sleep(10)
     except:
       self.tearDown()
       raise
     try:
       self.testdoc = self.client.GetDoc(self.testdoc.resource_id.text)
       self.testfile = self.client.Upload(
           'test.bin', 'My Binary File', content_type='application/octet-stream')
       # Because of an etag change issue, we must sleep for a few seconds
       time.sleep(10)
       self.testfile = self.client.GetDoc(self.testfile.resource_id.text)
     except:
       self.tearDown()
       raise
Example #12
0
  def testCreateUpdateDelete(self):
    if not conf.options.get_value('runlive') == 'true':
      return

    # Either load the recording or prepare to make a live request.
    conf.configure_cache(self.client, 'testCreateUpdateDelete')

    new_entry = self.client.CreateResource(
        'CR-NYC-14-12-BR', 'Boardroom',
        ('This conference room is in New York City, building 14, floor 12, '
         'Boardroom'), 'CR')

    self.assert_(isinstance(new_entry,
        gdata.calendar_resource.data.CalendarResourceEntry))
    self.assertEqual(new_entry.resource_id, 'CR-NYC-14-12-BR')
    self.assertEqual(new_entry.resource_common_name, 'Boardroom')
    self.assertEqual(new_entry.resource_description,
        ('This conference room is in New York City, building 14, floor 12, '
         'Boardroom'))
    self.assertEqual(new_entry.resource_type, 'CR')

    new_entry.resource_id = 'CR-MTV-14-12-BR'
    new_entry.resource_common_name = 'Executive Boardroom'
    new_entry.resource_description = 'This conference room is in Mountain View'
    new_entry.resource_type = 'BR'
    updated_entry = self.client.update(new_entry)
    self.assert_(isinstance(updated_entry,
        gdata.calendar_resource.data.CalendarResourceEntry))
    self.assertEqual(updated_entry.resource_id, 'CR-MTV-14-12-BR')
    self.assertEqual(updated_entry.resource_common_name, 'Executive Boardroom')
    self.assertEqual(updated_entry.resource_description,
        'This conference room is in Mountain View')
    self.assertEqual(updated_entry.resource_type, 'BR')

    self.client.delete(updated_entry)
Example #13
0
  def test_profiles_query(self):
    if not conf.options.get_value('runlive') == 'true':
      return
    # Either load the recording or prepare to make a live request.
    conf.configure_cache(self.client, 'test_profiles_feed')

    query = gdata.contacts.client.ProfilesQuery(max_results=1)
    feed = self.client.get_profiles_feed(q=query)
    self.assert_(isinstance(feed, gdata.contacts.data.ProfilesFeed))
    self.assert_(len(feed.entry) == 1)

    # Needs at least 2 profiles in the feed to test the start-key
    # query param.
    next = feed.GetNextLink()
    feed = None
    if next:
      # Retrieve the start-key query param from the next link.
      uri = atom.http_core.Uri.parse_uri(next.href)
      if 'start-key' in uri.query:
        query.start_key = uri.query['start-key']
        feed = self.client.get_profiles_feed(q=query)
        self.assert_(isinstance(feed, gdata.contacts.data.ProfilesFeed))
        self.assert_(len(feed.entry) == 1)
        self.assert_(feed.GetSelfLink().href == next.href)
        # Compare with a feed retrieved with the next link.
        next_feed = self.client.get_profiles_feed(uri=next.href)
        self.assert_(len(next_feed.entry) == 1)
        self.assert_(next_feed.entry[0].id.text == feed.entry[0].id.text)
 def test_retrieve_video_entry(self):
   if not conf.options.get_value('runlive') == 'true':
     return
   # Either load the recording or prepare to make a live request.
   conf.configure_cache(self.client, 'test_retrieve_video_entry')
   entry = self.client.get_video_entry(video_id=conf.options.get_value('videoid'))
   self.assertTrue(entry.etag)
  def testCreateRetrieveUpdateDelete(self):
    if not conf.options.get_value('runlive') == 'true':
      return

    # Either load the recording or prepare to make a live request.
    conf.configure_cache(self.client, 'testCreateRetrieveUpdateDelete')

    customer_id = self.client.RetrieveCustomerId().GetCustomerId()
    rnd_number = random.randrange(0, 100001)
    org_unit_name = 'test_org_unit_name%s' % (rnd_number)
    org_unit_description = 'test_org_unit_description%s' % (rnd_number)
    org_unit_path = org_unit_name

    new_entry = self.client.CreateOrgUnit(customer_id, org_unit_name,
                                          parent_org_unit_path='/',
                                          description=org_unit_description,
                                          block_inheritance=False)
    self.assert_(isinstance(new_entry,
                            gdata.apps.organization.data.OrgUnitEntry))
    self.assertEquals(new_entry.org_unit_path, org_unit_path)

    entry = self.client.RetrieveOrgUnit(customer_id, org_unit_path)
    self.assert_(isinstance(entry,
                            gdata.apps.organization.data.OrgUnitEntry))
    self.assertEquals(entry.org_unit_name, org_unit_name)
    self.assertEquals(entry.org_unit_description, org_unit_description)
    self.assertEquals(entry.parent_org_unit_path, '')
    self.assertEquals(entry.org_unit_path, org_unit_path)
    self.assertEquals(entry.org_unit_block_inheritance, 'false')

    self.client.DeleteOrgUnit(customer_id, org_unit_name)
Example #16
0
  def testCreateUpdateDelete(self):
    if not conf.options.get_value('runlive') == 'true':
      return

    # Either load the recording or prepare to make a live request.
    conf.configure_cache(self.client, 'testCreateUpdateDelete')

    new_entry = self.client.CreatePage(
        'webpage', 'Title Of Page', '<b>Your html content</b>')

    self.assertEqual(new_entry.title.text, 'Title Of Page')
    self.assertEqual(new_entry.page_name.text, 'title-of-page')
    self.assert_(new_entry.GetAlternateLink().href is not None)
    self.assertEqual(new_entry.Kind(), 'webpage')

    # Change the title of the webpage we just added.
    new_entry.title.text = 'Edited'
    updated_entry = self.client.update(new_entry)

    self.assertEqual(updated_entry.title.text, 'Edited')
    self.assertEqual(updated_entry.page_name.text, 'title-of-page')
    self.assert_(isinstance(updated_entry, gdata.sites.data.ContentEntry))

    # Delete the test webpage from the Site.
    self.client.delete(updated_entry)
  def test_create_draft_post(self):
    if not conf.options.get_value('runlive') == 'true':
      return
    conf.configure_cache(self.client, 'test_create_draft_post')

    # Add a draft blog post.
    created = self.client.add_post(conf.options.get_value('blogid'),
                                   'draft test post from BloggerClientTest',
                                   'This should only be a draft.',
                                   labels=['test2', 'python'], draft=True)

    self.assertEqual(created.title.text,
                     'draft test post from BloggerClientTest')
    self.assertEqual(created.content.text, 'This should only be a draft.')
    self.assertEqual(len(created.category), 2)
    self.assert_(created.control is not None)
    self.assert_(created.control.draft is not None)
    self.assertEqual(created.control.draft.text, 'yes')
    
    # Publish the blog post. 
    created.control.draft.text = 'no'
    updated = self.client.update(created)

    if updated.control is not None and updated.control.draft is not None:
      self.assertNotEqual(updated.control.draft.text, 'yes')
      
    # Delete the test entry from the blog using the URL instead of the entry.
    self.client.delete(updated.find_edit_link())
Example #18
0
  def testCreateAndUploadToFilecabinet(self):
    if not conf.options.get_value('runlive') == 'true':
      return

    # Either load the recording or prepare to make a live request.
    conf.configure_cache(self.client, 'testCreateAndUploadToFilecabinet')

    filecabinet = self.client.CreatePage(
        'filecabinet', 'FilesGoHere', '<b>Your html content</b>',
        page_name='diff-pagename-than-title')

    self.assertEqual(filecabinet.title.text, 'FilesGoHere')
    self.assertEqual(filecabinet.page_name.text, 'diff-pagename-than-title')
    self.assert_(filecabinet.GetAlternateLink().href is not None)
    self.assertEqual(filecabinet.Kind(), 'filecabinet')

    # Upload a file to the filecabinet
    filepath = conf.options.get_value('imgpath')
    attachment = self.client.UploadAttachment(
        filepath, filecabinet, content_type='image/jpeg', title='TestImageFile',
        description='description here')

    self.assertEqual(attachment.title.text, 'TestImageFile')
    self.assertEqual(attachment.FindParentLink(),
                     filecabinet.GetSelfLink().href)

    # Delete the test filecabinet and attachment from the Site.
    self.client.delete(attachment)
    self.client.delete(filecabinet)
  def test_create_update_delete(self):
    if not conf.options.get_value('runlive') == 'true':
      return
    # Either load the recording or prepare to make a live request.
    conf.configure_cache(self.client, 'test_create_update_delete')

    # Add a blog post.
    created = self.client.add_post(conf.options.get_value('blogid'),
                                   'test post from BloggerClientTest',
                                   'Hey look, another test!',
                                   labels=['test', 'python'])

    self.assertEqual(created.title.text, 'test post from BloggerClientTest')
    self.assertEqual(created.content.text, 'Hey look, another test!')
    self.assertEqual(len(created.category), 2)
    self.assert_(created.control is None)

    # Change the title of the blog post we just added.
    created.title.text = 'Edited'
    updated = self.client.update(created)

    self.assertEqual(updated.title.text, 'Edited')
    self.assert_(isinstance(updated, gdata.blogger.data.BlogPost))
    self.assertEqual(updated.content.text, created.content.text)

    # Delete the test entry from the blog.
    self.client.delete(updated)
Example #20
0
  def testGetLicenseNotifications(self):
    if not conf.options.get_value('runlive') == 'true':
      return

    # Either load the recording or prepare to make a live request.
    conf.configure_cache(self.client, 'testGetLicenseNotifications')
    
    fetched_feed = self.client.GetLicenseNotifications(app_id=self.app_id, max_results=2)
    self.assertTrue(isinstance(fetched_feed, gdata.marketplace.data.LicenseFeed))
    self.assertEqual(len(fetched_feed.entry), 2)
    for entry in fetched_feed.entry:
      entity = entry.content.entity
      self.assertTrue(entity is not None)
      self.assertNotEqual(entity.id, '')
      self.assertNotEqual(entity.domain_name, '')
      self.assertNotEqual(entity.installer_email, '')
      self.assertNotEqual(entity.tos_acceptance_time, '')
      self.assertNotEqual(entity.last_change_time, '')
      self.assertNotEqual(entity.product_config_id, '')
      self.assertNotEqual(entity.state, '')
    
    next_uri = fetched_feed.find_next_link()
    fetched_feed_next = self.client.GetLicenseNotifications(uri=next_uri)
    self.assertTrue(isinstance(fetched_feed_next, gdata.marketplace.data.LicenseFeed))
    self.assertTrue(len(fetched_feed_next.entry) <= 2)
    for entry in fetched_feed_next.entry:
      entity = entry.content.entity
      self.assertTrue(entity is not None)
      self.assertNotEqual(entity.id, '')
      self.assertNotEqual(entity.domain_name, '')
      self.assertNotEqual(entity.installer_email, '')
      self.assertNotEqual(entity.tos_acceptance_time, '')
      self.assertNotEqual(entity.last_change_time, '')
      self.assertNotEqual(entity.product_config_id, '')
      self.assertNotEqual(entity.state, '')
    def testCreateAndUploadToFilecabinet(self):
        if not conf.options.get_value("runlive") == "true":
            return

        # Either load the recording or prepare to make a live request.
        conf.configure_cache(self.client, "testCreateAndUploadToFilecabinet")

        filecabinet = self.client.CreatePage(
            "filecabinet", "FilesGoHere", "<b>Your html content</b>", page_name="diff-pagename-than-title"
        )

        self.assertEqual(filecabinet.title.text, "FilesGoHere")
        self.assertEqual(filecabinet.page_name.text, "diff-pagename-than-title")
        self.assertTrue(filecabinet.GetAlternateLink().href is not None)
        self.assertEqual(filecabinet.Kind(), "filecabinet")

        # Upload a file to the filecabinet
        filepath = conf.options.get_value("imgpath")
        attachment = self.client.UploadAttachment(
            filepath, filecabinet, content_type="image/jpeg", title="TestImageFile", description="description here"
        )

        self.assertEqual(attachment.title.text, "TestImageFile")
        self.assertEqual(attachment.FindParentLink(), filecabinet.GetSelfLink().href)

        # Delete the test filecabinet and attachment from the Site.
        self.client.delete(attachment)
        self.client.delete(filecabinet)
Example #22
0
  def test_create_update_delete_worksheet(self):
    if not conf.options.get_value('runlive') == 'true':
      return
    # Either load the recording or prepare to make a live request.
    conf.configure_cache(self.client, 'test_create_update_delete_worksheet')

    spreadsheet_id = conf.options.get_value('spreadsheetid')
    original_worksheets = self.client.get_worksheets(spreadsheet_id)
    self.assert_(isinstance(original_worksheets,
                               gdata.spreadsheets.data.WorksheetsFeed))
    worksheet_count = int(original_worksheets.total_results.text)

    # Add a new worksheet to the spreadsheet.
    created = self.client.add_worksheet(
        spreadsheet_id, 'a test worksheet', 4, 8)
    self.assert_(isinstance(created,
                               gdata.spreadsheets.data.WorksheetEntry))
    self.assertEqual(created.title.text, 'a test worksheet')
    self.assertEqual(created.row_count.text, '4')
    self.assertEqual(created.col_count.text, '8')

    # There should now be one more worksheet in this spreadsheet.
    updated_worksheets = self.client.get_worksheets(spreadsheet_id)
    new_worksheet_count = int(updated_worksheets.total_results.text)
    self.assertEqual(worksheet_count + 1, new_worksheet_count)

    # Delete our test worksheet.
    self.client.delete(created)
    # We should be back to the original number of worksheets.
    updated_worksheets = self.client.get_worksheets(spreadsheet_id)
    new_worksheet_count = int(updated_worksheets.total_results.text)
    self.assertEqual(worksheet_count, new_worksheet_count)
Example #23
0
    def testUpdatePop(self):
        if not conf.options.get_value('runlive') == 'true':
            return

        # Either load the recording or prepare to make a live request.
        conf.configure_cache(self.client, 'testUpdatePop')

        new_pop = self.client.UpdatePop(
            username=conf.options.get_value('targetusername'),
            enable=True,
            enable_for='MAIL_FROM_NOW_ON',
            action='KEEP')

        self.assertTrue(
            isinstance(new_pop,
                       gdata.apps.emailsettings.data.EmailSettingsPop))
        self.assertEqual(new_pop.enable, 'True')
        self.assertEqual(new_pop.enable_for, 'MAIL_FROM_NOW_ON')
        self.assertEqual(new_pop.action, 'KEEP')

        new_pop = self.client.UpdatePop(
            username=conf.options.get_value('targetusername'), enable=False)

        self.assertTrue(
            isinstance(new_pop,
                       gdata.apps.emailsettings.data.EmailSettingsPop))
        self.assertEqual(new_pop.enable, 'False')
Example #24
0
    def testUpdateGeneral(self):
        if not conf.options.get_value('runlive') == 'true':
            return

        # Either load the recording or prepare to make a live request.
        conf.configure_cache(self.client, 'testUpdateGeneral')

        new_general = self.client.UpdateGeneralSettings(
            username=conf.options.get_value('targetusername'),
            page_size=25,
            arrows=True)

        self.assertTrue(
            isinstance(new_general,
                       gdata.apps.emailsettings.data.EmailSettingsGeneral))
        self.assertEqual(new_general.page_size, '25')
        self.assertEqual(new_general.arrows, 'True')

        new_general = self.client.UpdateGeneralSettings(
            username=conf.options.get_value('targetusername'),
            shortcuts=False,
            snippets=True,
            use_unicode=False)

        self.assertTrue(
            isinstance(new_general,
                       gdata.apps.emailsettings.data.EmailSettingsGeneral))
        self.assertEqual(new_general.shortcuts, 'False')
        self.assertEqual(new_general.snippets, 'True')
        self.assertEqual(new_general.use_unicode, 'False')
Example #25
0
    def testUpdateForwarding(self):
        if not conf.options.get_value('runlive') == 'true':
            return

        # Either load the recording or prepare to make a live request.
        conf.configure_cache(self.client, 'testUpdateForwarding')

        new_forwarding = self.client.UpdateForwarding(
            username=conf.options.get_value('targetusername'),
            enable=True,
            forward_to=conf.options.get_value('appsusername'),
            action='KEEP')

        self.assertTrue(
            isinstance(new_forwarding,
                       gdata.apps.emailsettings.data.EmailSettingsForwarding))
        self.assertEqual(new_forwarding.enable, 'True')
        self.assertEqual(new_forwarding.forward_to,
                         conf.options.get_value('appsusername'))
        self.assertEqual(new_forwarding.action, 'KEEP')

        new_forwarding = self.client.UpdateForwarding(
            username=conf.options.get_value('targetusername'), enable=False)

        self.assertTrue(
            isinstance(new_forwarding,
                       gdata.apps.emailsettings.data.EmailSettingsForwarding))
        self.assertEqual(new_forwarding.enable, 'False')
Example #26
0
    def test_create_update_delete_worksheet(self):
        if not conf.options.get_value('runlive') == 'true':
            return
        # Either load the recording or prepare to make a live request.
        conf.configure_cache(self.client,
                             'test_create_update_delete_worksheet')

        spreadsheet_id = conf.options.get_value('spreadsheetid')
        original_worksheets = self.client.get_worksheets(spreadsheet_id)
        self.assert_(
            isinstance(original_worksheets,
                       gdata.spreadsheets.data.WorksheetsFeed))
        worksheet_count = int(original_worksheets.total_results.text)

        # Add a new worksheet to the spreadsheet.
        created = self.client.add_worksheet(spreadsheet_id, 'a test worksheet',
                                            4, 8)
        self.assert_(
            isinstance(created, gdata.spreadsheets.data.WorksheetEntry))
        self.assertEqual(created.title.text, 'a test worksheet')
        self.assertEqual(created.row_count.text, '4')
        self.assertEqual(created.col_count.text, '8')

        # There should now be one more worksheet in this spreadsheet.
        updated_worksheets = self.client.get_worksheets(spreadsheet_id)
        new_worksheet_count = int(updated_worksheets.total_results.text)
        self.assertEqual(worksheet_count + 1, new_worksheet_count)

        # Delete our test worksheet.
        self.client.delete(created)
        # We should be back to the original number of worksheets.
        updated_worksheets = self.client.get_worksheets(spreadsheet_id)
        new_worksheet_count = int(updated_worksheets.total_results.text)
        self.assertEqual(worksheet_count, new_worksheet_count)
Example #27
0
    def test_get_and_update_cell(self):
        if not conf.options.get_value('runlive') == 'true':
            return
        # Either load the recording or prepare to make a live request.
        conf.configure_cache(self.client, 'test_get_and_update_cell')

        spreadsheet_id = conf.options.get_value('spreadsheetid')

        test_worksheet = self.client.add_worksheet(spreadsheet_id,
                                                   'worksheet x',
                                                   rows=30,
                                                   cols=3)

        # Get a cell and set its value.
        cell_entry = self.client.get_cell(spreadsheet_id,
                                          test_worksheet.get_worksheet_id(), 1,
                                          1)
        cell_entry.cell.input_value = 'a test'
        result = self.client.update(cell_entry)
        self.assertEquals(cell_entry.cell.input_value, result.cell.input_value)

        # Verify that the value was set.
        cells = self.client.get_cells(spreadsheet_id,
                                      test_worksheet.get_worksheet_id())
        self.assertEquals(len(cells.entry), 1)
        self.assertEquals(cells.entry[0].cell.input_value, 'a test')

        # Delete the test worksheet.
        self.client.delete(test_worksheet, force=True)
    def testUpdateVacation(self):
        if not conf.options.get_value('runlive') == 'true':
            return

        # Either load the recording or prepare to make a live request.
        conf.configure_cache(self.client, 'testUpdateVacation')

        new_vacation = self.client.UpdateVacation(
            username=conf.options.get_value('targetusername'),
            enable=True,
            subject='Out of office',
            message='If urgent call me at 555-5555.',
            contacts_only=True)

        self.assert_(
            isinstance(
                new_vacation,
                gdata.apps.emailsettings.data.EmailSettingsVacationResponder))
        self.assertEqual(new_vacation.enable, 'True')
        self.assertEqual(new_vacation.subject, 'Out of office')
        self.assertEqual(new_vacation.message,
                         'If urgent call me at 555-5555.')
        self.assertEqual(new_vacation.contacts_only, 'True')

        new_vacation = self.client.UpdateVacation(
            username=conf.options.get_value('targetusername'), enable=False)

        self.assert_(
            isinstance(
                new_vacation,
                gdata.apps.emailsettings.data.EmailSettingsVacationResponder))
        self.assertEqual(new_vacation.enable, 'False')
Example #29
0
    def test_profiles_query(self):
        if not conf.options.get_value('runlive') == 'true':
            return
        # Either load the recording or prepare to make a live request.
        conf.configure_cache(self.client, 'test_profiles_feed')

        query = gdata.contacts.client.ProfilesQuery(max_results=1)
        feed = self.client.get_profiles_feed(q=query)
        self.assertTrue(isinstance(feed, gdata.contacts.data.ProfilesFeed))
        self.assertTrue(len(feed.entry) == 1)

        # Needs at least 2 profiles in the feed to test the start-key
        # query param.
        next = feed.GetNextLink()
        feed = None
        if next:
            # Retrieve the start-key query param from the next link.
            uri = atom.http_core.Uri.parse_uri(next.href)
            if 'start-key' in uri.query:
                query.start_key = uri.query['start-key']
                feed = self.client.get_profiles_feed(q=query)
                self.assertTrue(
                    isinstance(feed, gdata.contacts.data.ProfilesFeed))
                self.assertTrue(len(feed.entry) == 1)
                self.assertTrue(feed.GetSelfLink().href == next.href)
                # Compare with a feed retrieved with the next link.
                next_feed = self.client.get_profiles_feed(uri=next.href)
                self.assertTrue(len(next_feed.entry) == 1)
                self.assertTrue(
                    next_feed.entry[0].id.text == feed.entry[0].id.text)
Example #30
0
    def test_create_update_delete(self):
        if not conf.settings.RUN_LIVE_TESTS:
            return
        # Either load the recording or prepare to make a live request.
        conf.configure_cache(self.client, 'test_create_update_delete')

        # Add a blog post.
        created = self.client.add_post(conf.settings.BloggerConfig.blog_id,
                                       conf.settings.BloggerConfig.title,
                                       conf.settings.BloggerConfig.content,
                                       labels=['test', 'python'])

        self.assertEqual(created.title.text, conf.settings.BloggerConfig.title)
        self.assertEqual(created.content.text,
                         conf.settings.BloggerConfig.content)
        self.assertEqual(len(created.category), 2)
        self.assertTrue(created.control is None)

        # Change the title of the blog post we just added.
        created.title.text = 'Edited'
        updated = self.client.update(created)

        self.assertEqual(updated.title.text, 'Edited')
        self.assertTrue(isinstance(updated, gdata.blogger.data.BlogPost))
        self.assertEqual(updated.content.text, created.content.text)

        # Delete the test entry from the blog.
        self.client.delete(updated)
Example #31
0
  def test_version_two_client(self):
    if not conf.options.get_value('runlive') == 'true':
      return
    conf.configure_cache(self.client, 'test_version_two_client')

    entry = gdata.data.GDEntry()
    entry._other_elements.append(
        create_element('title', ATOM, 'Test', {'type': 'text'}))
    entry._other_elements.append(
        create_element('email', GD, 
            attributes={'address': '*****@*****.**', 'rel': WORK_REL}))

    # Create the test contact.
    posted = self.client.post(entry,
        'https://www.google.com/m8/feeds/contacts/default/full')
    self.assert_(isinstance(posted, gdata.data.GDEntry))
    self.assertEqual(posted.get_elements('title')[0].text, 'Test')
    self.assertEqual(posted.get_elements('email')[0].get_attributes(
        'address')[0].value, '*****@*****.**')

    posted.get_elements('title')[0].text = 'Doug'
    edited = self.client.update(posted)
    self.assert_(isinstance(edited, gdata.data.GDEntry))
    self.assertEqual(edited.get_elements('title')[0].text, 'Doug')
    self.assertEqual(edited.get_elements('email')[0].get_attributes(
        'address')[0].value, '*****@*****.**')

    # Delete the test contact.
    self.client.delete(edited)
  def test_create_update_delete(self):
    if not conf.options.get_value('runlive') == 'true':
      return
    # Either load the recording or prepare to make a live request.
    conf.configure_cache(self.client, 'test_create_update_delete')

    # Add a blog post.
    created = self.client.add_post(conf.options.get_value('blogid'),
                                   'test post from BloggerClientTest',
                                   'Hey look, another test!',
                                   labels=['test', 'python'])

    self.assertEqual(created.title.text, 'test post from BloggerClientTest')
    self.assertEqual(created.content.text, 'Hey look, another test!')
    self.assertEqual(len(created.category), 2)
    self.assertTrue(created.control is None)

    # Change the title of the blog post we just added.
    created.title.text = 'Edited'
    updated = self.client.update(created)

    self.assertEqual(updated.title.text, 'Edited')
    self.assertTrue(isinstance(updated, gdata.blogger.data.BlogPost))
    self.assertEqual(updated.content.text, created.content.text)

    # Delete the test entry from the blog.
    self.client.delete(updated)
Example #33
0
    def testDataFeed(self):
        """Tests if the Data Feed exists."""

        start_date = '2008-10-01'
        end_date = '2008-10-02'
        metrics = 'ga:visits'

        if not conf.options.get_value('runlive') == 'true':
            return
        conf.configure_cache(self.client, 'testDataFeed')

        data_query = gdata.analytics.client.DataFeedQuery({
            'ids':
            conf.options.get_value('table_id'),
            'start-date':
            start_date,
            'end-date':
            end_date,
            'metrics':
            metrics,
            'max-results':
            '1'
        })
        feed = self.client.GetDataFeed(data_query)

        self.assertTrue(feed.entry is not None)
        self.assertEqual(feed.start_date.text, start_date)
        self.assertEqual(feed.end_date.text, end_date)
        self.assertEqual(feed.entry[0].GetMetric(metrics).name, metrics)
    def test_get_comments(self):
        if not conf.options.get_value('runlive') == 'true':
            return
        # Either load the recording or prepare to make a live request.
        conf.configure_cache(self.client, 'test_create_update_delete')

        # Create an issue so we have something to look up.
        created = self.create_issue()

        # The fully qualified id is a url, we just want the number.
        issue_id = created.id.text.split('/')[-1]

        # Now lets add two comments to that issue.
        for i in range(2):
            update_response = self.client.update_issue(
                self.project_name,
                issue_id,
                self.owner,
                comment='My comment here %s' % i)

        # We have an issue that has several comments. Lets get them.
        comments_feed = self.client.get_comments(self.project_name, issue_id)

        # It has 2 comments.
        self.assertEqual(2, len(comments_feed.entry))
Example #35
0
  def testUpdateVacation(self):
    if not conf.options.get_value('runlive') == 'true':
      return

    # Either load the recording or prepare to make a live request.
    conf.configure_cache(self.client, 'testUpdateVacation')

    new_vacation = self.client.UpdateVacation(
        username=conf.options.get_value('targetusername'),
        enable=True, subject='Out of office',
        message='If urgent call me at 555-5555.',
        contacts_only=True)

    self.assert_(isinstance(new_vacation,
        gdata.apps.emailsettings.data.EmailSettingsVacationResponder))
    self.assertEqual(new_vacation.enable, 'True')
    self.assertEqual(new_vacation.subject, 'Out of office')
    self.assertEqual(new_vacation.message, 'If urgent call me at 555-5555.')
    self.assertEqual(new_vacation.contacts_only, 'True')

    new_vacation = self.client.UpdateVacation(
        username=conf.options.get_value('targetusername'),
        enable=False)

    self.assert_(isinstance(new_vacation,
        gdata.apps.emailsettings.data.EmailSettingsVacationResponder))
    self.assertEqual(new_vacation.enable, 'False')
Example #36
0
  def test_version_two_client(self):
    if not conf.options.get_value('runlive') == 'true':
      return
    conf.configure_cache(self.client, 'test_version_two_client')

    entry = gdata.data.GDEntry()
    entry._other_elements.append(
        create_element('title', ATOM, 'Test', {'type': 'text'}))
    entry._other_elements.append(
        create_element('email', GD, 
            attributes={'address': '*****@*****.**', 'rel': WORK_REL}))

    # Create the test contact.
    posted = self.client.post(entry,
        'https://www.google.com/m8/feeds/contacts/default/full')
    self.assert_(isinstance(posted, gdata.data.GDEntry))
    self.assertEqual(posted.get_elements('title')[0].text, 'Test')
    self.assertEqual(posted.get_elements('email')[0].get_attributes(
        'address')[0].value, '*****@*****.**')

    posted.get_elements('title')[0].text = 'Doug'
    edited = self.client.update(posted)
    self.assert_(isinstance(edited, gdata.data.GDEntry))
    self.assertEqual(edited.get_elements('title')[0].text, 'Doug')
    self.assertEqual(edited.get_elements('email')[0].get_attributes(
        'address')[0].value, '*****@*****.**')

    # Delete the test contact.
    self.client.delete(edited)
Example #37
0
    def test_create_draft_post(self):
        if not conf.settings.RUN_LIVE_TESTS:
            return
        conf.configure_cache(self.client, 'test_create_draft_post')

        # Add a draft blog post.
        created = self.client.add_post(conf.settings.BloggerConfig.blog_id,
                                       conf.settings.BloggerConfig.title,
                                       conf.settings.BloggerConfig.content,
                                       labels=['test2', 'python'],
                                       draft=True)

        self.assertEqual(created.title.text, conf.settings.BloggerConfig.title)
        self.assertEqual(created.content.text,
                         conf.settings.BloggerConfig.content)
        self.assertEqual(len(created.category), 2)
        self.assertTrue(created.control is not None)
        self.assertTrue(created.control.draft is not None)
        self.assertEqual(created.control.draft.text, 'yes')

        # Publish the blog post.
        created.control.draft.text = 'no'
        updated = self.client.update(created)

        if updated.control is not None and updated.control.draft is not None:
            self.assertNotEqual(updated.control.draft.text, 'yes')

        # Delete the test entry from the blog using the URL instead of the entry.
        self.client.delete(updated.find_edit_link())
Example #38
0
  def testUpdateForwarding(self):
    if not conf.options.get_value('runlive') == 'true':
      return

    # Either load the recording or prepare to make a live request.
    conf.configure_cache(self.client, 'testUpdateForwarding')

    new_forwarding = self.client.UpdateForwarding(
        username=conf.options.get_value('targetusername'),
        enable=True,
        forward_to=conf.options.get_value('appsusername'),
        action='KEEP')

    self.assert_(isinstance(new_forwarding,
        gdata.apps.emailsettings.data.EmailSettingsForwarding))
    self.assertEqual(new_forwarding.enable, 'True')
    self.assertEqual(new_forwarding.forward_to,
        conf.options.get_value('appsusername'))
    self.assertEqual(new_forwarding.action, 'KEEP')

    new_forwarding = self.client.UpdateForwarding(
        username=conf.options.get_value('targetusername'),
        enable=False)

    self.assert_(isinstance(new_forwarding,
        gdata.apps.emailsettings.data.EmailSettingsForwarding))
    self.assertEqual(new_forwarding.enable, 'False')
Example #39
0
    def testUploadEntireDocumentAndUpdate(self):
        if not conf.options.get_value('runlive') == 'true':
            return

        # Either load the recording or prepare to make a live request.
        conf.configure_cache(self.client, 'testUploadDocument')

        uploader = gdata.client.ResumableUploader(
            self.client,
            self.f,
            self.content_type,
            os.path.getsize(self.f.name),
            chunk_size=20000,  # 20000 bytes.
            desired_class=gdata.docs.data.DocsEntry)

        e = gdata.docs.data.DocsEntry(title=atom.data.Title(
            text='MyResumableTitleEntireFile'))
        e.category.append(gdata.docs.data.make_kind_category('document'))
        e.writers_can_invite = gdata.docs.data.WritersCanInvite(value='false')

        entry = uploader.UploadFile(
            '/feeds/upload/create-session/default/private/full', entry=e)

        # Verify upload has really completed.
        self.assertEqual(uploader.QueryUploadStatus(), True)

        self.assert_(isinstance(entry, gdata.docs.data.DocsEntry))
        self.assertEqual(entry.title.text, 'MyResumableTitleEntireFile')
        self.assertEqual(entry.GetDocumentType(), 'document')
        self.assertEqual(entry.writers_can_invite.value, 'false')
        self.assertEqual(int(entry.quota_bytes_used.text), 0)
        self.client.Delete(entry, force=True)
Example #40
0
    def testUploadDocumentInChunks(self):
        if not conf.options.get_value('runlive') == 'true':
            return

        # Either load the recording or prepare to make a live request.
        conf.configure_cache(self.client, 'testUploadDocumentInChunks')

        uploader = gdata.client.ResumableUploader(
            self.client,
            self.f,
            self.content_type,
            os.path.getsize(self.f.name),
            desired_class=gdata.docs.data.DocsEntry)

        uploader._InitSession(
            '/feeds/upload/create-session/default/private/full',
            headers={'Slug': 'MyManualChunksNoAtomTitle'})

        start_byte = 0
        entry = None

        while not entry:
            entry = uploader.UploadChunk(
                start_byte, uploader.file_handle.read(uploader.chunk_size))
            start_byte += uploader.chunk_size

        # Verify upload has really completed.
        self.assertEqual(uploader.QueryUploadStatus(), True)

        self.assert_(isinstance(entry, gdata.docs.data.DocsEntry))
        self.assertEqual(entry.title.text, 'MyManualChunksNoAtomTitle')
        self.assertEqual(entry.GetDocumentType(), 'document')
        self.client.Delete(entry, force=True)
  def testAccountFeed(self):
    """Tests if the Account Feed exists."""

    if not conf.options.get_value('runlive') == 'true':
      return
    conf.configure_cache(self.client, 'testAccountFeed')

    account_query = gdata.analytics.client.AccountFeedQuery({
        'max-results': '1'
    })

    feed = self.client.GetAccountFeed(account_query)
    self.assert_(feed.entry is not None)

    properties = [
        'ga:accountId',
        'ga:accountName',
        'ga:profileId',
        'ga:webPropertyId',
        'ga:currency',
        'ga:timezone'
    ]

    entry = feed.entry[0]
    for prop in properties:
      property = entry.GetProperty(prop)
      self.assertEquals(property.name, prop)
Example #42
0
    def test_create_unlisted_map(self):
        if not conf.options.get_value('runlive') == 'true':
            return
        conf.configure_cache(self.client, 'test_create_unlisted_map')

        # Add an unlisted map.
        created = self.client.create_map('An unlisted test map',
                                         'This should be unlisted.',
                                         unlisted=True)

        self.assertEqual(created.title.text, 'An unlisted test map')
        self.assertEqual(created.summary.text, 'This should be unlisted.')
        self.assert_(created.control is not None)
        self.assert_(created.control.draft is not None)
        self.assertEqual(created.control.draft.text, 'yes')

        # Make the map public.
        created.control.draft.text = 'no'
        updated = self.client.update(created)

        if updated.control is not None and updated.control.draft is not None:
            self.assertNotEqual(updated.control.draft.text, 'yes')

        # Delete the test map using the URL instead of the entry.
        self.client.delete(updated.find_edit_link())
Example #43
0
    def test_create_update_delete_map(self):
        if not conf.options.get_value('runlive') == 'true':
            return
        # Either load the recording or prepare to make a live request.
        conf.configure_cache(self.client, 'test_create_update_delete_map')

        # Create a map.
        created = self.client.create_map('A test map',
                                         'This map is just a little test.')

        self.assertEqual(created.title.text, 'A test map')
        self.assertEqual(created.summary.text,
                         'This map is just a little test.')
        self.assert_(created.control is None)

        # Change the title of the map we just added.
        created.title.text = 'Edited'
        updated = self.client.update(created)

        self.assertEqual(updated.title.text, 'Edited')
        self.assert_(isinstance(updated, gdata.maps.data.Map))
        self.assertEqual(updated.content.text, created.content.text)

        # Delete the test map.
        self.client.delete(updated)
  def test_create_draft_post(self):
    if not conf.options.get_value('runlive') == 'true':
      return
    conf.configure_cache(self.client, 'test_create_draft_post')

    # Add a draft blog post.
    created = self.client.add_post(conf.options.get_value('blogid'),
                                   'draft test post from BloggerClientTest',
                                   'This should only be a draft.',
                                   labels=['test2', 'python'], draft=True)

    self.assertEqual(created.title.text,
                     'draft test post from BloggerClientTest')
    self.assertEqual(created.content.text, 'This should only be a draft.')
    self.assertEqual(len(created.category), 2)
    self.assertTrue(created.control is not None)
    self.assertTrue(created.control.draft is not None)
    self.assertEqual(created.control.draft.text, 'yes')
    
    # Publish the blog post. 
    created.control.draft.text = 'no'
    updated = self.client.update(created)

    if updated.control is not None and updated.control.draft is not None:
      self.assertNotEqual(updated.control.draft.text, 'yes')
      
    # Delete the test entry from the blog using the URL instead of the entry.
    self.client.delete(updated.find_edit_link())
Example #45
0
  def test_get_and_update_cell(self):
    if not conf.options.get_value('runlive') == 'true':
      return
    # Either load the recording or prepare to make a live request.
    conf.configure_cache(self.client, 'test_get_and_update_cell')

    spreadsheet_id = conf.options.get_value('spreadsheetid')

    test_worksheet = self.client.add_worksheet(
        spreadsheet_id, 'worksheet x', rows=30, cols=3)

    # Get a cell and set its value.
    cell_entry = self.client.get_cell(
        spreadsheet_id, test_worksheet.get_worksheet_id(), 1, 1)
    cell_entry.cell.input_value = 'a test'
    result = self.client.update(cell_entry)
    self.assertEquals(cell_entry.cell.input_value, result.cell.input_value)

    # Verify that the value was set.
    cells = self.client.get_cells(
        spreadsheet_id, test_worksheet.get_worksheet_id())
    self.assertEquals(len(cells.entry), 1)
    self.assertEquals(cells.entry[0].cell.input_value, 'a test')

    # Delete the test worksheet.
    self.client.delete(test_worksheet, force=True)
Example #46
0
  def testUpdateGeneral(self):
    if not conf.options.get_value('runlive') == 'true':
      return

    # Either load the recording or prepare to make a live request.
    conf.configure_cache(self.client, 'testUpdateGeneral')

    new_general = self.client.UpdateGeneralSettings(
        username=conf.options.get_value('targetusername'),
        page_size=25, arrows=True)

    self.assert_(isinstance(new_general,
        gdata.apps.emailsettings.data.EmailSettingsGeneral))
    self.assertEqual(new_general.page_size, '25')
    self.assertEqual(new_general.arrows, 'True')

    new_general = self.client.UpdateGeneralSettings(
        username=conf.options.get_value('targetusername'),
        shortcuts=False, snippets=True, use_unicode=False)

    self.assert_(isinstance(new_general,
        gdata.apps.emailsettings.data.EmailSettingsGeneral))
    self.assertEqual(new_general.shortcuts, 'False')
    self.assertEqual(new_general.snippets, 'True')
    self.assertEqual(new_general.use_unicode, 'False')
Example #47
0
    def testCreateUpdateDelete(self):
        if not conf.options.get_value('runlive') == 'true':
            return

        # Either load the recording or prepare to make a live request.
        conf.configure_cache(self.client, 'testCreateUpdateDelete')

        new_entry = self.client.CreatePage('webpage', 'Title Of Page',
                                           '<b>Your html content</b>')

        self.assertEqual(new_entry.title.text, 'Title Of Page')
        self.assertEqual(new_entry.page_name.text, 'title-of-page')
        self.assertTrue(new_entry.GetAlternateLink().href is not None)
        self.assertEqual(new_entry.Kind(), 'webpage')

        # Change the title of the webpage we just added.
        new_entry.title.text = 'Edited'
        updated_entry = self.client.update(new_entry)

        self.assertEqual(updated_entry.title.text, 'Edited')
        self.assertEqual(updated_entry.page_name.text, 'title-of-page')
        self.assertTrue(
            isinstance(updated_entry, gdata.sites.data.ContentEntry))

        # Delete the test webpage from the Site.
        self.client.delete(updated_entry)
Example #48
0
    def testCreateAndUploadToFilecabinet(self):
        if not conf.options.get_value('runlive') == 'true':
            return

        # Either load the recording or prepare to make a live request.
        conf.configure_cache(self.client, 'testCreateAndUploadToFilecabinet')

        filecabinet = self.client.CreatePage(
            'filecabinet',
            'FilesGoHere',
            '<b>Your html content</b>',
            page_name='diff-pagename-than-title')

        self.assertEqual(filecabinet.title.text, 'FilesGoHere')
        self.assertEqual(filecabinet.page_name.text,
                         'diff-pagename-than-title')
        self.assertTrue(filecabinet.GetAlternateLink().href is not None)
        self.assertEqual(filecabinet.Kind(), 'filecabinet')

        # Upload a file to the filecabinet
        filepath = conf.options.get_value('imgpath')
        attachment = self.client.UploadAttachment(
            filepath,
            filecabinet,
            content_type='image/jpeg',
            title='TestImageFile',
            description='description here')

        self.assertEqual(attachment.title.text, 'TestImageFile')
        self.assertEqual(attachment.FindParentLink(),
                         filecabinet.GetSelfLink().href)

        # Delete the test filecabinet and attachment from the Site.
        self.client.delete(attachment)
        self.client.delete(filecabinet)
  def testUploadDocumentInChunks(self):
    if not conf.options.get_value('runlive') == 'true':
      return

    # Either load the recording or prepare to make a live request.
    conf.configure_cache(self.client, 'testUploadDocumentInChunks')

    uploader = gdata.client.ResumableUploader(
        self.client, self.f, self.content_type, os.path.getsize(self.f.name),
        desired_class=gdata.docs.data.DocsEntry)

    uploader._InitSession(
        '/feeds/upload/create-session/default/private/full',
        headers={'Slug': 'MyManualChunksNoAtomTitle'})

    start_byte = 0
    entry = None

    while not entry:
      entry = uploader.UploadChunk(
          start_byte, uploader.file_handle.read(uploader.chunk_size))
      start_byte += uploader.chunk_size

    # Verify upload has really completed.
    self.assertEqual(uploader.QueryUploadStatus(), True)

    self.assert_(isinstance(entry, gdata.docs.data.DocsEntry))
    self.assertEqual(entry.title.text, 'MyManualChunksNoAtomTitle')
    self.assertEqual(entry.GetDocumentType(), 'document')
    self.client.Delete(entry, force=True)
  def testUploadEntireDocumentAndUpdate(self):
    if not conf.options.get_value('runlive') == 'true':
      return

    # Either load the recording or prepare to make a live request.
    conf.configure_cache(self.client, 'testUploadDocument')

    uploader = gdata.client.ResumableUploader(
        self.client, self.f, self.content_type, os.path.getsize(self.f.name),
        chunk_size=20000,  # 20000 bytes.
        desired_class=gdata.docs.data.DocsEntry)

    e = gdata.docs.data.DocsEntry(
        title=atom.data.Title(text='MyResumableTitleEntireFile'))
    e.category.append(gdata.docs.data.make_kind_category('document'))
    e.writers_can_invite = gdata.docs.data.WritersCanInvite(value='false')

    entry = uploader.UploadFile(
        '/feeds/upload/create-session/default/private/full', entry=e)

    # Verify upload has really completed.
    self.assertEqual(uploader.QueryUploadStatus(), True)

    self.assert_(isinstance(entry, gdata.docs.data.DocsEntry))
    self.assertEqual(entry.title.text, 'MyResumableTitleEntireFile')
    self.assertEqual(entry.GetDocumentType(), 'document')
    self.assertEqual(entry.writers_can_invite.value, 'false')
    self.assertEqual(int(entry.quota_bytes_used.text), 0)
    self.client.Delete(entry, force=True)
Example #51
0
  def testCreateRetrieveUpdateDelete(self):
    if not conf.options.get_value('runlive') == 'true':
      return

    # Either load the recording or prepare to make a live request.
    conf.configure_cache(self.client, 'testCreateUpdateDelete')
    
    rnd_number = random.randrange(0, 100001)
    email = 'test_user%s@%s' % (rnd_number, self.client.domain)
    alias = 'test_alias%s@%s' % (rnd_number, self.client.domain)

    new_entry = self.client.CreateUser(
        email, 'Elizabeth', 'Smith',
        '51eea05d46317fadd5cad6787a8f562be90b4446', 'true',
        hash_function='SHA-1')

    self.assert_(isinstance(new_entry,
        gdata.apps.multidomain.data.UserEntry))
    self.assertEquals(new_entry.first_name, 'Elizabeth')
    self.assertEquals(new_entry.last_name, 'Smith')
    self.assertEquals(new_entry.email, email)
    self.assertEquals(new_entry.password,
        '51eea05d46317fadd5cad6787a8f562be90b4446')
    self.assertEquals(new_entry.is_admin, 'true')

    fetched_entry = self.client.RetrieveUser(email=email)
    self.assertEquals(fetched_entry.first_name, 'Elizabeth')
    self.assertEquals(fetched_entry.last_name, 'Smith')
    self.assertEquals(fetched_entry.email, email)
    self.assertEquals(fetched_entry.is_admin, 'true')

    new_entry.first_name = 'Joe'
    new_entry.last_name = 'Brown'
    updated_entry = self.client.UpdateUser(
        email=email, user_entry=new_entry)
    self.assert_(isinstance(updated_entry,
        gdata.apps.multidomain.data.UserEntry))
    self.assertEqual(updated_entry.first_name, 'Joe')
    self.assertEqual(updated_entry.last_name, 'Brown')

    new_email = 'renamed_user%s@%s' % (rnd_number, self.client.domain)
    renamed_entry = self.client.RenameUser(
        old_email=email, new_email=new_email)
    self.assert_(isinstance(renamed_entry,
        gdata.apps.multidomain.data.UserRenameRequest))
    self.assertEqual(renamed_entry.new_email, new_email)

    new_alias = self.client.CreateAlias(new_email, alias)
    self.assert_(isinstance(new_alias,
        gdata.apps.multidomain.data.AliasEntry))
    self.assertEquals(new_alias.user_email, new_email)
    self.assertEquals(new_alias.alias_email, alias)

    fetched_alias = self.client.RetrieveAlias(alias)
    self.assertEquals(fetched_alias.user_email, new_email)
    self.assertEquals(fetched_alias.alias_email, alias)

    self.client.DeleteAlias(alias)
    self.client.DeleteUser(new_email)
  def test_retrieve_user_feed(self):
    if not conf.options.get_value('runlive') == 'true':
      return
    # Either load the recording or prepare to make a live request.
    conf.configure_cache(self.client, 'test_retrieve_video_has_entries')

    entries = self.client.get_user_feed(username='******')
    self.assertTrue(len(entries.entry) > 0)
Example #53
0
    def test_retrieve_user_feed(self):
        if not conf.options.get_value('runlive') == 'true':
            return
        # Either load the recording or prepare to make a live request.
        conf.configure_cache(self.client, 'test_retrieve_video_has_entries')

        entries = self.client.get_user_feed(username='******')
        self.assertTrue(len(entries.entry) > 0)
Example #54
0
  def test_profiles_feed(self):
    if not conf.options.get_value('runlive') == 'true':
      return
    # Either load the recording or prepare to make a live request.
    conf.configure_cache(self.client, 'test_profiles_feed')

    feed = self.client.get_profiles_feed()
    self.assert_(isinstance(feed, gdata.contacts.data.ProfilesFeed))
Example #55
0
    def test_profiles_feed(self):
        if not conf.options.get_value('runlive') == 'true':
            return
        # Either load the recording or prepare to make a live request.
        conf.configure_cache(self.client, 'test_profiles_feed')

        feed = self.client.get_profiles_feed()
        self.assertTrue(isinstance(feed, gdata.contacts.data.ProfilesFeed))
Example #56
0
 def setUp(self):
   if conf.options.get_value('runlive') != 'true':
     raise RuntimeError('Live tests require --runlive true')
   else:
     self.client = gdata.docs.client.DocsClient()
     if conf.options.get_value('ssl') == 'true':
       self.client.ssl = True
     conf.configure_client(self.client, 'DocsTest', self.client.auth_service)
     conf.configure_cache(self.client, str(self.__class__))
     if conf.options.get_value('clean') == 'true':
       self._delete_all()
Example #57
0
    def testManagementFeed(self):
        """Tests of the Management Feed exists."""

        if not conf.options.get_value('runlive') == 'true':
            return
        conf.configure_cache(self.client, 'testManagementFeed')

        account_query = gdata.analytics.client.AccountQuery()
        feed = self.client.GetManagementFeed(account_query)

        self.assertTrue(feed.entry is not None)
 def setUp(self):
     if conf.options.get_value("runlive") != "true":
         raise RuntimeError("Live tests require --runlive true")
     else:
         self.client = gdata.docs.client.DocsClient()
         if conf.options.get_value("ssl") == "true":
             self.client.ssl = True
         conf.configure_client(self.client, "DocsTest", self.client.auth_service)
         conf.configure_cache(self.client, str(self.__class__))
         if conf.options.get_value("clean") == "true":
             self._delete_all()
Example #59
0
 def setUp(self):
   if conf.options.get_value('runlive') != 'true':
     raise RuntimeError('Live tests require --runlive true')
   else:
     self.client = gdata.docs.client.DocsClient()
     if conf.options.get_value('ssl') == 'true':
       self.client.ssl = True
     conf.configure_client(self.client, 'DocsTest', self.client.auth_service)
     conf.configure_cache(self.client, str(self.__class__))
     if conf.options.get_value('clean') == 'true':
       self._delete_all()