Ejemplo n.º 1
0
def test_update_edit_params():
  '''
    Test basic update editing with all the params
  '''

  mocked_api = MagicMock()
  mocked_api.post.return_value = {
      'update': {'id': 1, 'text': 'hey!'}
  }

  update = Update(mocked_api, raw_response={'id':1, 'text': 'ola!'})
  new_update = update.edit(text='hey!', media={'link':'w'}, utc="a", now=True)

  assert_update = Update(mocked_api, raw_response={'id':1, 'text': 'hey!'})

  post_data = 'text=hey!&now=True&utc=a&media[link]=w&'
  mocked_api.post.assert_called_once_with(url='updates/1/update.json',
      data=post_data)
  eq_(new_update, assert_update)
Ejemplo n.º 2
0
def test_update_edit():
  '''
    Test basic update editing
  '''

  mocked_api = MagicMock()
  mocked_api.post.return_value = {
      'update': {'id': 1, 'text': 'hey!'}
  }

  update = Update(mocked_api, raw_response={'id':1, 'text': 'ola!'})
  new_update = update.edit(text='hey!')

  assert_update = Update(mocked_api, raw_response={'id':1, 'text': 'hey!'})

  post_data = 'text=hey!&'
  mocked_api.post.assert_called_once_with(url='updates/1/update.json',
      data=post_data)
  eq_(new_update, assert_update)
Ejemplo n.º 3
0
from bufferapp.models.update import Update
from bufferapp.managers.profiles import Profiles
from bufferapp.managers.updates import Updates
from bufferapp.api import API

# check http://bufferapp.com/developers/apps to retrieve a token
# or generate one with the example
token = 'awesome_token'

# instantiate the api object
api = API(client_id='client_id',
          client_secret='client_secret',
          access_token=token)

# retrieve a single update based on an id
update = Update(api=api, id='update_id')
print update

# get update's interactions
print update.interactions

# edit
update = update.edit(text="Hey!")

# publish now
update.publish()

# move to top
update.move_to_top()

# delete