예제 #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)
예제 #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)
예제 #3
0
    def edit(self, j, newTitle=''):
        logging.info("New title %s", newTitle)
        thePost = self.obtainPostData(j)
        oldTitle = thePost[0]
        if not newTitle:
            newTitle = self.reorderTitle(oldTitle)
        profile = self.getProfile()
        logging.info("servicename %s" %self.service)
        from buffpy.models.update import Update
        i=0
        update = Update(api=self.client, id=profile.updates.pending[j].id) 
        print(update)
        update = update.edit(text=newTitle)

        title = oldTitle
        update = "Changed "+title+" with "+newTitle

        logging.info("Res update %s" % update)

        return(update)
예제 #4
0
    def editl(self, j, newLink=''):
        logging.info("New link %s", newLink)
        thePost = self.obtainPostData(j)
        oldLink = thePost[1]
        profile = self.getProfile()
        logging.info("servicename %s" %self.service)
        from buffpy.models.update import Update
        i=0
        update = Update(api=self.client, id=profile.updates.pending[j].id) 
        print(update)
        # media = {'original': newLink } 
        return('Not implemented!')
        update = update.edit(text=newTitle)

        title = oldTitle
        update = "Changed "+title+" with "+newTitle

        logging.info("Res update %s" % update)

        return(update)
예제 #5
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)
    assert new_update == assert_update
예제 #6
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)
    assert new_update == assert_update
예제 #7
0
from buffpy.managers.updates import Updates
from buffpy.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
update.delete()
예제 #8
0
파일: update.py 프로젝트: vtemian/buffpy
from buffpy.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
update.delete()